From 8df774017fee726ab6b035223f008862c46000d4 Mon Sep 17 00:00:00 2001 From: "Adam J. Jackson" Date: Tue, 11 Feb 2025 10:01:07 +0000 Subject: [PATCH] Build landing page from version.yml --- .github/workflows/create-landing-page.yml | 16 +++++++++++----- .github/workflows/release.yml | 14 ++++++++++++++ .github/workflows/set_version.yml | 16 ++++++++++++---- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/.github/workflows/create-landing-page.yml b/.github/workflows/create-landing-page.yml index 30aab5019..1eecec854 100644 --- a/.github/workflows/create-landing-page.yml +++ b/.github/workflows/create-landing-page.yml @@ -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: @@ -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' + 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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9c0f1fc7..8ddddab0f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,6 +26,12 @@ jobs: version: ${{ inputs.version }} push: true + show_tag: + runs-on: ubuntu-latest + needs: prepare + steps: + - run: echo NORMALISED TAG: ${{ needs.prepare.outputs.tag }} + build-sdist: needs: prepare name: Build and test sdist @@ -97,3 +103,11 @@ jobs: # - 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 }} diff --git a/.github/workflows/set_version.yml b/.github/workflows/set_version.yml index c9e103135..8eb0eedc1 100644 --- a/.github/workflows/set_version.yml +++ b/.github/workflows/set_version.yml @@ -33,10 +33,16 @@ on: type: boolean default: false required: false + outputs: + tag: + description: "Normalised version tag" + value: ${{ jobs.set_version.outputs.tag }} jobs: - set-version: + set_version: runs-on: ubuntu-latest + outputs: + tag: ${{ steps.normalise.outputs.VERSION_STRING }} steps: - uses: actions/setup-python@v5 @@ -47,6 +53,7 @@ jobs: run: python -m pip install toolz packaging - name: Validate and normalise version number + id: normalise shell: python run : | import os @@ -57,9 +64,10 @@ jobs: print(f"Normalised version string: {version_string}") - with open(os.environ["GITHUB_ENV"], "a") as github_env: - print(f"VERSION_NUMBER={version_number}", file=github_env) - print(f"VERSION_STRING={version_string}", file=github_env) + for github_target in "GITHUB_ENV", "GITHUB_OUTPUT": + with open(os.environ[github_target], "a") as target: + print(f"VERSION_NUMBER={version_number}", file=target) + print(f"VERSION_STRING={version_string}", file=target) # From a workflow call we might already have working copy; in that # case inputs.ref should be an empty string. Otherwise, checkout.