|
5 | 5 | branches: [main] |
6 | 6 |
|
7 | 7 | jobs: |
8 | | - release-package: |
| 8 | + release-please: |
9 | 9 | runs-on: ubuntu-latest |
10 | 10 | permissions: |
11 | | - id-token: write # Needed if using OIDC to get release secrets. |
12 | | - contents: write # Contents and pull-requests are for release-please to make releases. |
| 11 | + contents: write |
13 | 12 | pull-requests: write |
14 | | - attestations: write # Needed for artifact attestations |
| 13 | + outputs: |
| 14 | + releases_created: ${{ steps.release.outputs.releases_created }} |
15 | 15 | steps: |
| 16 | + # Create any releases first, then create tags, and then optionally create any new PRs. |
16 | 17 | - uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0 |
17 | 18 | id: release |
| 19 | + with: |
| 20 | + skip-github-pull-request: true |
| 21 | + |
| 22 | + # Need the repository content to be able to create and push a tag. |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + if: ${{ steps.release.outputs.release_created == 'true' }} |
| 25 | + |
| 26 | + - name: Create release tag |
| 27 | + if: ${{ steps.release.outputs.release_created == 'true' }} |
| 28 | + env: |
| 29 | + TAG_NAME: ${{ steps.release.outputs.tag_name }} |
| 30 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + run: | |
| 32 | + if gh api "repos/${{ github.repository }}/git/ref/tags/${TAG_NAME}" >/dev/null 2>&1; then |
| 33 | + echo "Tag ${TAG_NAME} already exists, skipping creation." |
| 34 | + else |
| 35 | + echo "Creating tag ${TAG_NAME}." |
| 36 | + git config user.name "github-actions[bot]" |
| 37 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 38 | + git tag "${TAG_NAME}" |
| 39 | + git push origin "${TAG_NAME}" |
| 40 | + fi |
| 41 | +
|
| 42 | + - uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0 |
| 43 | + if: ${{ steps.release.outputs.release_created != 'true' }} |
| 44 | + id: release-prs |
| 45 | + with: |
| 46 | + skip-github-release: true |
18 | 47 |
|
| 48 | + release-package: |
| 49 | + needs: release-please |
| 50 | + if: ${{ needs.release-please.outputs.releases_created == 'true' }} |
| 51 | + runs-on: ubuntu-latest |
| 52 | + permissions: |
| 53 | + id-token: write # Needed if using OIDC to get release secrets. |
| 54 | + contents: write # Contents and pull-requests are for release-please to make releases. |
| 55 | + attestations: write # Needed for artifact attestations |
| 56 | + steps: |
19 | 57 | - uses: actions/checkout@v4 |
20 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
21 | 58 | with: |
22 | 59 | fetch-depth: 0 |
23 | 60 |
|
24 | 61 | - uses: actions/setup-python@v5 |
25 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
26 | 62 | with: |
27 | 63 | python-version: "3.10" |
28 | 64 |
|
29 | 65 | - name: Install poetry |
30 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
31 | 66 | uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439 # v3.0.0 |
32 | 67 |
|
33 | 68 | - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0 |
34 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
35 | 69 | name: "Get PyPI token" |
36 | 70 | with: |
37 | 71 | aws_assume_role: ${{ vars.AWS_ROLE_ARN }} |
38 | 72 | ssm_parameter_pairs: "/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN" |
39 | 73 |
|
40 | 74 | - uses: ./.github/actions/build |
41 | 75 | id: build |
42 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
43 | 76 |
|
44 | 77 | - uses: ./.github/actions/build-docs |
45 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
46 | 78 |
|
47 | 79 | - name: Publish package distributions to PyPI |
48 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
49 | 80 | uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 |
50 | 81 | with: |
51 | 82 | password: ${{env.PYPI_AUTH_TOKEN}} |
52 | 83 |
|
53 | 84 | - name: Attest build provenance |
54 | | - if: ${{ steps.release.outputs.releases_created == 'true' }} |
55 | 85 | uses: actions/attest@v4 |
56 | 86 | with: |
57 | 87 | subject-path: 'dist/*' |
0 commit comments