Skip to content

Commit

Permalink
Build landing page from version.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ajjackson committed Feb 11, 2025
1 parent c018ced commit 8df7740
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
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'
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
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
16 changes: 12 additions & 4 deletions .github/workflows/set_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 8df7740

Please sign in to comment.