Skip to content

Bump actions/download-artifact from 4.2.1 to 4.3.0 (#992) #112

Bump actions/download-artifact from 4.2.1 to 4.3.0 (#992)

Bump actions/download-artifact from 4.2.1 to 4.3.0 (#992) #112

Workflow file for this run

name: Python 🐍🐍🐍 Test 🦂 Build 🧱 Release 🚰 and Publish 📦
on:
push:
branches:
- 'main'
paths:
- 'python/**'
- '!python/**.md'
- '!python/.vscode/**'
- '.github/workflows/python-*'
workflow_dispatch:
permissions: {}
defaults:
run:
shell: bash
working-directory: python
env:
development_python_version: 3.10.12
jobs:
context:
name: GitHub 🐱‍👤 Context 📑
uses: ./.github/workflows/github-context.yaml
test:
name: Python 🐍🐍🐍 Test 🦂
permissions:
actions: read
contents: read
security-events: write
uses: ./.github/workflows/python-test.yaml
workflow-conditions:
name: 🛑🛑🛑 Stop builds that didn't change the release version 🛑🛑🛑
runs-on: ubuntu-latest
outputs:
version-file-changed: ${{ steps.version-file-check.outputs.version-file-changed }}
version-tag-exists: ${{ steps.version-tag-exists.outputs.version-tag-exists }}
steps:
- name: 🏁 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 2
- name: Check if version files changed
id: version-file-check
run: |
export VERSION_FILE="python/src/collatz/__version__.py"
[ "$(git diff HEAD^1.. --name-only | grep -e "^$VERSION_FILE$")" == "$VERSION_FILE" ] && echo "version-file-changed=${{toJSON(true)}}" >> $GITHUB_OUTPUT || echo "version-file-changed=${{toJSON(false)}}" >> $GITHUB_OUTPUT
- name: Notify on version-file-check
run: echo "::Notice::version-file-changed is ${{ fromJSON(steps.version-file-check.outputs.version-file-changed) }}"
- name: Check if version specified in version file has not released.
id: version-tag-exists
run: |
git fetch --tags
export VER=$(cut -d \" -f 2 src/collatz/__version__.py)
[ -z "$(git tag -l "python-v$VER")" ] && echo "version-tag-exists=${{toJSON(false)}}" >> $GITHUB_OUTPUT || echo "version-tag-exists=${{toJSON(true)}}" >> $GITHUB_OUTPUT
- name: Notify on version-tag-exists
run: echo "::Notice::version-tag-exists is ${{ fromJSON(steps.version-tag-exists.outputs.version-tag-exists) }}"
# Now any step that should only run on the version change can use
# "needs: [workflow-conditions]" Which will yield the condition checks below.
# We want to "release" automatically if "version-file-changed" is true on push
# Or manually if workflow_dispatch. BOTH need "version-tag-exists" is false.
build:
name: Python 🐍🐍🐍 Build 🧱
needs: [test, workflow-conditions]
if: >-
${{ ((fromJSON(needs.workflow-conditions.outputs.version-file-changed) == true && github.event_name == 'push') ||
github.event_name == 'workflow_dispatch') && fromJSON(needs.workflow-conditions.outputs.version-tag-exists) == false }}
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 🐍🐍🐍 Set up Python
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
with:
python-version: ${{ env.development_python_version }}
- name: 🧱 Install build dependencies
run: make venv
- name: 🎡 Build wheel and source
run: make build
- name: 🆙 Upload dists
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: built-dists
path: python/dist/
if-no-files-found: error
release:
name: Python 🐍🐍🐍 Release 🚰
needs: [build]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 🆒 Download dists
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: built-dists
path: python/dist
- name: 🚰 Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
export VER=$(cut -d \" -f 2 src/collatz/__version__.py) &&
gh release create
python-v$VER
"$(find dist | grep \\-none\\-any\\.whl)#Wheel"
"$(find dist | grep \\.tar\\.gz)#Tarball"
--generate-notes
-t "Python: Version $VER"
publish:
name: Python 🐍🐍🐍 Publish 📦
needs: [release]
runs-on: ubuntu-latest
steps:
# Although the dists are built uses checkout to satisfy refs/tags existence
# which were created by the release, prior to uploading to pypi.
- name: 🏁 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 🆒 Download dists
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: built-dists
path: python/dist
- name: 📦 Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
packages_dir: python/dist
skip_existing: true
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: 📦 Publish to PyPI
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
packages_dir: python/dist
password: ${{ secrets.PYPI_API_TOKEN }}
docs:
name: Python 🐍🐍🐍 Docs 📄
needs: [release, publish]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 🐍🐍🐍 Set up Python
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
with:
python-version: ${{ env.development_python_version }}
- name: 🧱 Install build dependencies
run: make venv
- name: 📄 Docs Generation
run: make docs
- name: 📄 Docs Publishing
run: |-
git config --local user.email "actions@github.com"
git config --local user.name "Github Actions"
export SHORTSHA=$(git rev-parse --short HEAD)
git fetch origin gh-pages-python:gh-pages-python
git symbolic-ref HEAD refs/heads/gh-pages-python
cd .. && mv python/docs/build ../MERGE_TARGET
git rm -rf . && git clean -fxd && git reset
shopt -s dotglob && mkdir python && mv ../MERGE_TARGET/* python/
git add .
git commit -m "Build based on $SHORTSHA" --allow-empty
git push --set-upstream origin gh-pages-python
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docs-merge:
name: GitHub 🐱‍👤 Pages 📄 Merger 🧬
needs: [docs]
permissions:
contents: write
pages: write
id-token: write
uses: ./.github/workflows/github-pages.yaml
with:
merge_from: 'gh-pages-python'