Skip to content

Update github actions versions #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .github/actions/run-in-container/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Run in container
description: Run a command in a container
author: Daniel Flook

inputs:
image:
description: The image to run the command in
required: true
run:
description: The command to run
required: true
volumes:
description: Volumes to mount, one per line. Each line of the form 'source:target'
required: false
default: ""

runs:
using: composite
steps:
- name: Run command
env:
INPUT_VOLUMES: ${{ inputs.volumes }}
run: |

docker pull --quiet ${{ inputs.image }}

function run() {
docker run --rm \
--workdir /github/workspace \
-e "GITHUB_WORKSPACE=/github/workspace" \
-v $GITHUB_WORKSPACE:/github/workspace \
-e "HOME=/github/home" \
-v "$RUNNER_TEMP/_github_home":"/github/home" \
-v "/var/run/docker.sock":"/var/run/docker.sock" \
--mount type=bind,source="$RUNNER_TEMP/run.sh",target=/run.sh,readonly \
-e GITHUB_EVENT_PATH \
--mount type=bind,source="$GITHUB_EVENT_PATH",target="$GITHUB_EVENT_PATH,readonly" \
-e GITHUB_PATH \
--mount type=bind,source="$GITHUB_PATH",target="$GITHUB_PATH" \
-e GITHUB_ENV \
--mount type=bind,source="$GITHUB_ENV",target="$GITHUB_ENV" \
-e GITHUB_STEP_SUMMARY \
--mount type=bind,source="$GITHUB_STEP_SUMMARY",target="$GITHUB_STEP_SUMMARY" \
-e GITHUB_TOKEN \
-e GITHUB_JOB \
-e GITHUB_REF \
-e GITHUB_SHA \
-e GITHUB_REPOSITORY \
-e GITHUB_REPOSITORY_OWNER \
-e GITHUB_RUN_ID \
-e GITHUB_RUN_NUMBER \
-e GITHUB_RETENTION_DAYS \
-e GITHUB_RUN_ATTEMPT \
-e GITHUB_ACTOR \
-e GITHUB_WORKFLOW \
-e GITHUB_HEAD_REF \
-e GITHUB_BASE_REF \
-e GITHUB_EVENT_NAME \
-e GITHUB_SERVER_URL \
-e GITHUB_API_URL \
-e GITHUB_GRAPHQL_URL \
-e GITHUB_ACTION \
-e GITHUB_ACTION_REPOSITORY \
-e GITHUB_ACTION_REF \
-e RUNNER_DEBUG \
-e RUNNER_OS \
-e RUNNER_NAME \
-e RUNNER_TOOL_CACHE \
-e ACTIONS_RUNTIME_URL \
-e ACTIONS_RUNTIME_TOKEN \
-e ACTIONS_CACHE_URL \
-e GITHUB_ACTIONS \
-e CI \
-e GITHUB_ACTOR_ID \
-e GITHUB_OUTPUT \
-e GITHUB_REF_NAME \
-e GITHUB_REF_PROTECTED \
-e GITHUB_REF_TYPE \
-e GITHUB_REPOSITORY_ID \
-e GITHUB_REPOSITORY_OWNER_ID \
-e GITHUB_TRIGGERING_ACTOR \
-e GITHUB_WORKFLOW_REF \
-e GITHUB_WORKFLOW_SHA \
$VOLUMES_ARGS \
--entrypoint /bin/bash \
${{ inputs.image }} \
--noprofile --norc -eo pipefail /run.sh

}

function fix_owners() {
cat <<"EOF" >"$RUNNER_TEMP/run.sh"
chown -R --reference "$GITHUB_WORKSPACE" "$GITHUB_WORKSPACE/" || true
chown -R --reference "/github/home" "/github/home/" || true
chown --reference "$GITHUB_WORKSPACE" $GITHUB_PATH || true
chown --reference "$GITHUB_WORKSPACE" $GITHUB_ENV || true
chown --reference "$GITHUB_WORKSPACE" $GITHUB_STEP_SUMMARY || true
EOF
VOLUMES_ARGS=""
run
rm -f "$RUNNER_TEMP/run.sh"
}

trap fix_owners EXIT

VOLUMES_ARGS=""
if [[ -n "$INPUT_VOLUMES" ]]; then
for mount in $(echo "$INPUT_VOLUMES" | tr ',' '\n'); do
VOLUMES_ARGS="$VOLUMES_ARGS -v $mount"
done
fi

cat <<"EOF" >"$RUNNER_TEMP/run.sh"
${{ inputs.run }}
EOF

set -x
run
set +x

shell: bash

branding:
icon: globe
color: purple
28 changes: 18 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,34 @@ concurrency:
group: release
cancel-in-progress: false

env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

jobs:

release:
name: Create sdist and Python 3 Wheel
runs-on: ubuntu-latest
container:
image: danielflook/python-minifier-build:python3.13-2024-09-15
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
fetch-tags: 'true'
show-progress: 'false'

- name: Set version statically
run: |
VERSION=${{ github.event.release.tag_name }}
sed -i "s/setup_requires=.*/version='$VERSION',/; s/use_scm_version=.*//" setup.py
echo "Version: $VERSION"

- name: Build package
- name: Build distribution packages
run: |
pip3 install --upgrade build
python3 -m build

- uses: actions/upload-artifact@v3
- name: Upload distribution artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
Expand All @@ -43,11 +47,13 @@ jobs:
pip3 install dist/*.tar.gz
sphinx-build docs/source /tmp/build

- uses: actions/upload-pages-artifact@v1
- name: Upload documentation artifact
uses: actions/upload-pages-artifact@v3
with:
path: /tmp/build

publish-to-pypi:
name: Publish to PyPI
needs: release
runs-on: ubuntu-latest
permissions:
Expand All @@ -56,18 +62,20 @@ jobs:
name: pypi
url: https://pypi.org/project/python-minifier/${{ github.event.release.tag_name }}
steps:
- uses: actions/download-artifact@v3
- name: Download distribution artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@release/v1.10.1
with:
print-hash: true
verbose: true

publish-docs:
name: Publish Documentation
needs: release
runs-on: ubuntu-latest
permissions:
Expand All @@ -79,4 +87,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
Loading