Skip to content
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

One-step release action #368

Merged
merged 29 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
09c0dea
Make push optional for set-version action
ajjackson Feb 7, 2025
b41ae28
Enable workflow_call for set-version action
ajjackson Feb 7, 2025
2d1084a
Allow workflow call to skip checkout
ajjackson Feb 7, 2025
87afa69
Implement CHANGELOG parser; no bumping yet
ajjackson Feb 7, 2025
e4ed583
Implement CHANGELOG bumping script; minor re-render of CHANGELOG
ajjackson Feb 7, 2025
157288e
Tidy up bump_changelog.py
ajjackson Feb 7, 2025
c3d8d9d
Bump CHANGELOG from set_version action
ajjackson Feb 7, 2025
17e8b21
More linting, replace itertools.batched with itertoolz.partition
ajjackson Feb 7, 2025
a0089fa
Update "Unreleased" diff URL when updating CHANGELOG
ajjackson Feb 7, 2025
848ab79
Developing release action: split up build actions, no release yet
ajjackson Feb 10, 2025
4e08cf6
Need to checkout or the actions can't be found
ajjackson Feb 10, 2025
488a013
Reusable workflows: call at job level, not step
ajjackson Feb 10, 2025
7f4ca07
Maybe swapping these steps will improve Github visualisation
ajjackson Feb 10, 2025
51e6a48
Call release.py from release.yml if the builds look good
ajjackson Feb 10, 2025
10af9b1
release.py expects Euphonic to be installed already
ajjackson Feb 10, 2025
c93133e
release.py dependencies, linting
ajjackson Feb 10, 2025
c53b94f
release.py troubleshooting: check git log
ajjackson Feb 10, 2025
389376d
Correct version number format to CHANGELOG bumper
ajjackson Feb 10, 2025
1c4861d
Detect prerelease, supply GITHUB_TOKEN
ajjackson Feb 10, 2025
4ca7811
Remove debugging bits, restore build/test step
ajjackson Feb 10, 2025
c04b6cc
Build landing page from version.yml
ajjackson Feb 11, 2025
156dacd
Reusable workflow doesn't know it's a workflow_call
ajjackson Feb 11, 2025
03460f6
Remove debug and activate PyPI push in Release action
ajjackson Feb 11, 2025
699501d
CHANGELOG update
ajjackson Feb 11, 2025
e3c6661
Remove build-upload action, this has been broken into smaller parts
ajjackson Feb 11, 2025
ed16103
Apply suggestions from code review
ajjackson Feb 11, 2025
33ed3dd
Refactor bump_changelog: define link string in one place
ajjackson Feb 11, 2025
414dce5
Refactor bump_changelog: block printing to __str__ method
ajjackson Feb 11, 2025
c1f259b
Update build_utils/bump_changelog.py
ajjackson Feb 11, 2025
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
96 changes: 96 additions & 0 deletions .github/workflows/build_sdist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Build and test sdist

on:
workflow_dispatch:
inputs:
ref:
description: "Target branch / tag / commit"
required: true
type: string
workflow_call:
inputs:
ref:
description: "Target branch / tag / commit"
required: true
type: string

jobs:
build-sdist:
name: Build sdist
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
fetch-depth: 0
fetch-tags: true

- name: Create source distribution
shell: bash -l {0}
run: |
pipx run build --sdist .

- name: Upload source dist as build artifact
uses: actions/upload-artifact@v4
with:
name: python-source-distribution
path: dist/
if-no-files-found: error

test-sdist:
needs: build-sdist
name: Test build from sdist on Windows
oerc0122 marked this conversation as resolved.
Show resolved Hide resolved
runs-on: windows-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Find MSVC and set environment variables
shell: bash -l {0}
env:
MSVC_PREFIX: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC'
run: |
echo "Available MSVC installations:"
ls "$MSVC_PREFIX"

MSVC_BIN=$(ls "$MSVC_PREFIX" | tail -n 1)\\bin\\HostX64\\x64
CC="$MSVC_PREFIX\\$MSVC_BIN\\cl.exe"
echo "CC: $CC"
echo "CC=$CC" >> $GITHUB_ENV

CC_LD="$MSVC_PREFIX\\$MSVC_BIN\\link.exe"
echo "CC_LD: $CC_LD"
echo "CC_LD=$CC_LD" >> $GITHUB_ENV

- name: Download sdist
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true

- name: List downloaded sdist
run: |
ls -R dist/

- name: Update pip
shell: bash -l {0}
run: |
python -m pip install --upgrade pip

- name: Install from sdist
shell: bash -l {0}
run: python -m pip install $(find dist -name 'euphonic-*.tar.gz')[matplotlib,phonopy-reader,brille,test]

- name: Checkout repository (for tests and test data)
uses: actions/checkout@v4

- name: Delete source (to ensure we are testing INSTALLED version)
shell: bash -l {0}
run: rm -rf euphonic

- name: run tests
shell: bash -l {0}
run: python tests_and_analysis/test/run_tests.py --report
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
name: Build and upload PyPI wheels and source dist
name: Build and test Python wheels

on:
release:
types: [published]
workflow_dispatch:
inputs:
ref:
description: "Target branch / tag / commit"
required: true
type: string
workflow_call:
inputs:
ref:
description: "Target branch / tag / commit"
required: true
type: string

jobs:
build-wheels:
Expand Down Expand Up @@ -36,6 +45,7 @@ jobs:
- name: Checkout project
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
fetch-depth: 0
fetch-tags: true

Expand Down Expand Up @@ -101,111 +111,3 @@ jobs:
name: wheel-${{ matrix.wheelname }}-${{ matrix.python-version }}-${{ matrix.cibw_archs }}
path: wheelhouse/*-${{ matrix.wheelname }}*_${{ matrix.cibw_archs }}.whl
if-no-files-found: error

build-sdist:
name: Build sdist
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true


- name: Create source distribution
shell: bash -l {0}
run: |
pipx run build --sdist .

- name: Upload source dist as build artifact
uses: actions/upload-artifact@v4
with:
name: python-source-distribution
path: dist/
if-no-files-found: error

test-sdist:
needs: build-sdist
name: Test build from sdist on Windows
runs-on: windows-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Find MSVC and set environment variables
shell: bash -l {0}
env:
MSVC_PREFIX: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC'
run: |
echo "Available MSVC installations:"
ls "$MSVC_PREFIX"

MSVC_BIN=$(ls "$MSVC_PREFIX" | tail -n 1)\\bin\\HostX64\\x64
CC="$MSVC_PREFIX\\$MSVC_BIN\\cl.exe"
echo "CC: $CC"
echo "CC=$CC" >> $GITHUB_ENV

CC_LD="$MSVC_PREFIX\\$MSVC_BIN\\link.exe"
echo "CC_LD: $CC_LD"
echo "CC_LD=$CC_LD" >> $GITHUB_ENV

- name: Download sdist
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true

- name: List downloaded sdist
run: |
ls -R dist/

- name: Update pip
shell: bash -l {0}
run: |
python -m pip install --upgrade pip

- name: Install from sdist
shell: bash -l {0}
run: python -m pip install $(find dist -name 'euphonic-*.tar.gz')[matplotlib,phonopy-reader,brille,test]

- name: Checkout repository (for tests and test data)
uses: actions/checkout@v4

- name: Delete source (to ensure we are testing INSTALLED version)
shell: bash -l {0}
run: rm -rf euphonic

- name: run tests
shell: bash -l {0}
run: python tests_and_analysis/test/run_tests.py --report

publish:
if: github.event_name == 'release'
needs: [build-wheels,test-sdist]
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/euphonic
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # This is possibly unnecessary?

- name: Download artifacts to Ubuntu environment
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true

- name: List Files
run: ls -R dist/

- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
16 changes: 11 additions & 5 deletions .github/workflows/create-landing-page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ on:
- master
paths:
- 'CITATION.cff'
release:
types: [published]

workflow_call:
inputs:
ref:
description: "Target: 'latest' or tag"
required: true
type: string
default: latest

jobs:
update-landing-page:
Expand All @@ -26,9 +32,9 @@ jobs:
- name: Set env var based on (master) push trigger
if: github.event_name == 'push'
run: echo "PAGE_TYPE=latest" >> $GITHUB_ENV
- name: Set env var based on release
if: github.event_name == 'release'
run: echo "PAGE_TYPE=${{ github.event.release.name }}" >> $GITHUB_ENV
- name: Set env var based on workflow call
if: (github.event_name == 'workflow_call') || (github.event_name == 'workflow_dispatch')
run: echo "PAGE_TYPE=${{ inputs.ref }}" >> $GITHUB_ENV
- name: Create landing page
run: python write_doi_landing_page.py ${{ env.PAGE_TYPE }}
- uses: EndBug/add-and-commit@v9
Expand Down
94 changes: 93 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,96 @@ on:
required: true
type: string
push:
description: "Push commit, tag and release"
description: "Make release and push to PyPI"
required: true
type: boolean
default: false

jobs:
prepare:
name: Bump version number
uses: ./.github/workflows/set_version.yml
with:
ref: ${{ inputs.ref }}
version: ${{ inputs.version }}
push: true

build-sdist:
needs: prepare
name: Build and test sdist
uses: ./.github/workflows/build_sdist.yml
with:
ref: ${{ inputs.ref }}

build-wheels:
name: Build and test wheels
needs: prepare

uses: ./.github/workflows/build_wheels.yml
with:
ref: ${{ inputs.ref }}

release:
name: Github release
needs: [build-wheels,build-sdist]
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
fetch-depth: 1

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Basic installation to check euphonic.__version__
shell: bash -l {0}
run: |
python -m pip install requests pyyaml
python -m pip install .

- name: Check version consistency, generate Github release page
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run : |
python build_utils/release.py --github ${{ inputs.push && '--notest' || '' }}

publish:
if: ${{ inputs.push }}
needs: release
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/euphonic
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
fetch-depth: 0 # This is possibly unnecessary?

- name: Download artifacts to Ubuntu environment
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true

- name: List Files
run: ls -R dist/

- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

landing_page:
needs: [prepare,release]
if: ${{ inputs.push }}
name: Create landing page
uses: ./.github/workflows/create-landing-page.yml
with:
ref: ${{ needs.prepare.outputs.tag }}
Loading