Skip to content

Commit fb25f24

Browse files
committed
ci: use draft releases to support immutable GitHub releases
1 parent 68ea81e commit fb25f24

3 files changed

Lines changed: 57 additions & 14 deletions

File tree

.github/workflows/publish.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ jobs:
2525
permissions:
2626
id-token: write
2727
contents: write # Needed in this case to write github pages.
28+
attestations: write
2829
outputs:
29-
gem-hash: ${{ steps.publish.outputs.gem-hash}}
30+
gem-hash: ${{ steps.publish.outputs.gem-hash }}
3031
steps:
3132
- uses: actions/checkout@v4
3233

@@ -56,14 +57,13 @@ jobs:
5657
with:
5758
token: ${{secrets.GITHUB_TOKEN}}
5859

59-
release-provenance:
60-
needs: [ 'build-publish' ]
61-
permissions:
62-
actions: read
63-
id-token: write
64-
contents: write
65-
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
66-
with:
67-
base64-subjects: "${{ needs.build-publish.outputs.gem-hash }}"
68-
upload-assets: ${{ !inputs.dry_run }}
69-
upload-tag-name: ${{ needs.release-package.outputs.upload-tag-name }}
60+
- name: Generate checksums file
61+
env:
62+
HASHES: ${{ steps.publish.outputs.gem-hash }}
63+
run: |
64+
echo "$HASHES" | base64 -d > checksums.txt
65+
66+
- name: Attest build provenance
67+
uses: actions/attest@v4
68+
with:
69+
subject-checksums: checksums.txt

.github/workflows/release-please.yml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,53 @@ jobs:
1818
steps:
1919
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4
2020
id: release
21-
22-
release-sdk:
21+
22+
create-tag:
2323
needs: release-please
2424
if: ${{ needs.release-please.outputs.release-created == 'true' }}
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: write
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Create release tag
34+
env:
35+
TAG_NAME: ${{ needs.release-please.outputs.tag-name }}
36+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
if gh api "repos/${{ github.repository }}/git/ref/tags/${TAG_NAME}" >/dev/null 2>&1; then
39+
echo "Tag ${TAG_NAME} already exists, skipping creation."
40+
else
41+
echo "Creating tag ${TAG_NAME}."
42+
git config user.name "github-actions[bot]"
43+
git config user.email "github-actions[bot]@users.noreply.github.com"
44+
git tag "${TAG_NAME}"
45+
git push origin "${TAG_NAME}"
46+
fi
47+
48+
release-sdk:
49+
needs: ['release-please', 'create-tag']
50+
if: ${{ needs.release-please.outputs.release-created == 'true' }}
2551
uses: ./.github/workflows/publish.yml
2652
with:
2753
dry_run: false
2854
tag_name: ${{ needs.release-please.outputs.tag-name }}
55+
56+
publish-release:
57+
needs: ['release-please', 'release-sdk']
58+
if: ${{ needs.release-please.outputs.release-created == 'true' }}
59+
runs-on: ubuntu-latest
60+
permissions:
61+
contents: write
62+
steps:
63+
- name: Publish release
64+
env:
65+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
TAG_NAME: ${{ needs.release-please.outputs.tag-name }}
67+
run: >
68+
gh release edit "$TAG_NAME"
69+
--repo ${{ github.repository }}
70+
--draft=false

release-please-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"packages": {
33
".": {
44
"release-type": "ruby",
5+
"draft": true,
56
"bump-minor-pre-major": true,
67
"versioning": "default",
78
"include-component-in-tag": false,

0 commit comments

Comments
 (0)