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

Fix packaging workflows to correctly gate on the repo name. #185

Merged
merged 10 commits into from
Apr 3, 2024
32 changes: 22 additions & 10 deletions .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,20 @@ jobs:
echo "- release_level: ${{ inputs.release_level }}" >> $GITHUB_STEP_SUMMARY
echo "## Incoming Changes" >> $GITHUB_STEP_SUMMARY
cat python_semantic_release_templates/.previous_release_notes_for_template.md >> $GITHUB_STEP_SUMMARY
- name: Set outputs
id: variables
run: echo "repo-name=$REPO_NAME" >> $GITHUB_OUTPUT
outputs:
repo-name: ${{ steps.variables.outputs.repo-name }}
# This job requires a Personal Access Token (Classic) with
# the public_repo permission. It also needs a private/public
# ssh key pair that can be used for signing. The public key must
# be attached to the account as an SSH signing key.
pypi-version:
name: Update package version
needs: [print-inputs]
if: github.repository == env.REPO_NAME && github.ref == 'refs/heads/main'
if: github.repository == needs.print-inputs.outputs.repo-name && github.ref ==
'refs/heads/main'
runs-on: ubuntu-latest
environment: package-release-gate
permissions:
Expand Down Expand Up @@ -90,8 +96,9 @@ jobs:
built-version: ${{ steps.release.outputs.version }}
pypi-build:
name: Build package
needs: [pypi-version]
if: github.repository == env.REPO_NAME && github.ref == 'refs/heads/main'
needs: [print-inputs, pypi-version]
if: github.repository == needs.print-inputs.outputs.repo-name && github.ref ==
'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -102,8 +109,9 @@ jobs:
uses: hynek/[email protected]
upload-testpypi:
name: Upload package to TestPyPI
needs: [pypi-build]
if: github.repository == env.REPO_NAME && github.ref == 'refs/heads/main'
needs: [print-inputs, pypi-build]
if: github.repository == needs.print-inputs.outputs.repo-name && github.ref ==
'refs/heads/main'
runs-on: ubuntu-latest
environment: package-testpypi
permissions:
Expand All @@ -120,8 +128,9 @@ jobs:
repository-url: https://test.pypi.org/legacy/
upload-pypi:
name: Upload package to PyPI
needs: [upload-testpypi]
if: github.repository == env.REPO_NAME && github.ref == 'refs/heads/main'
needs: [print-inputs, upload-testpypi]
if: github.repository == needs.print-inputs.outputs.repo-name && github.ref ==
'refs/heads/main'
runs-on: ubuntu-latest
environment: package-release
permissions:
Expand All @@ -136,8 +145,9 @@ jobs:
uses: pypa/[email protected]
upload-github:
name: Upload package to GitHub Release
needs: [upload-pypi]
if: github.repository == env.REPO_NAME && github.ref == 'refs/heads/main'
needs: [print-inputs, upload-pypi]
if: github.repository == needs.print-inputs.outputs.repo-name && github.ref ==
'refs/heads/main'
runs-on: ubuntu-latest
permissions:
id-token: write
Expand All @@ -160,12 +170,14 @@ jobs:
pypi-install:
name: Install package
needs:
- print-inputs
- pypi-version
- pypi-build
- upload-testpypi
- upload-pypi
- upload-github
if: github.repository == env.REPO_NAME && github.ref == 'refs/heads/main'
if: github.repository == needs.print-inputs.outputs.repo-name && github.ref ==
'refs/heads/main'
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/package-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ env:
REPO_NAME: tektronix/${{ inputs.package-name || 'tm_devices' }}
PACKAGE_NAME: ${{ inputs.package-name || 'tm_devices' }}
jobs:
job-variables:
name: Set variables for other jobs to use
runs-on: ubuntu-latest
steps:
- name: Set variables
id: variables
run: echo "repo-name=$REPO_NAME" >> $GITHUB_OUTPUT
outputs:
repo-name: ${{ steps.variables.outputs.repo-name }}
test-pypi-build:
name: Build package with unique version for test.pypi.org
if: github.repository == env.REPO_NAME
needs: [job-variables]
if: github.repository == needs.job-variables.outputs.repo-name
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -46,8 +56,8 @@ jobs:
built-version: ${{ steps.create-version.outputs.NEW_VERSION }}
test-pypi-upload:
name: Upload package to test.pypi.org
needs: test-pypi-build
if: github.repository == env.REPO_NAME
needs: [job-variables, test-pypi-build]
if: github.repository == needs.job-variables.outputs.repo-name
runs-on: ubuntu-latest
environment: package-testpypi
permissions:
Expand All @@ -64,8 +74,8 @@ jobs:
repository-url: https://test.pypi.org/legacy/
test-pypi-install:
name: Install package from test.pypi.org
needs: [test-pypi-build, test-pypi-upload]
if: github.repository == env.REPO_NAME
needs: [job-variables, test-pypi-build, test-pypi-upload]
if: github.repository == needs.job-variables.outputs.repo-name
runs-on: ubuntu-latest
steps:
- name: Set up Python
Expand Down
Loading