Skip to content

Commit 178698a

Browse files
authored
update to work with immutable releases (#281)
Signed-off-by: Carlos Panato <ctadeu@gmail.com>
1 parent 3e0cb5e commit 178698a

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
outputs:
1515
hashes: ${{ steps.hash.outputs.hashes }}
16-
tag_name: ${{ steps.tag.outputs.tag_name }}
16+
tag_name: ${{ steps.get_tag.outputs.tag_name }}
1717

1818
runs-on: ubuntu-latest
1919

@@ -90,3 +90,24 @@ jobs:
9090
base64-subjects: "${{ needs.release.outputs.hashes }}"
9191
upload-assets: true # upload to a new release
9292
upload-tag-name: "${{ needs.release.outputs.tag_name }}"
93+
# GoReleaser leaves the release as a draft; keep it that way when
94+
# attaching the provenance, otherwise the upload would target an
95+
# immutable (published) release and fail.
96+
draft-release: "true"
97+
98+
# Publish the draft release only after every asset (GoReleaser artifacts and
99+
# SLSA provenance) has been attached, since a published release is immutable.
100+
publish-release:
101+
needs:
102+
- release
103+
- provenance
104+
runs-on: ubuntu-latest
105+
permissions:
106+
contents: write # To publish the draft release.
107+
steps:
108+
- name: Publish release
109+
env:
110+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
GH_REPO: ${{ github.repository }}
112+
TAG_NAME: ${{ needs.release.outputs.tag_name }}
113+
run: gh release edit "${TAG_NAME}" --draft=false

.goreleaser.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ builds:
2828
- arm64
2929
- arm
3030
goarm:
31-
- 7
31+
- "7"
3232
ldflags: |
3333
-X github.com/prometheus/common/version.Version={{.Version}}
3434
-X github.com/prometheus/common/version.Revision={{.Commit}}
@@ -37,7 +37,8 @@ builds:
3737
-X github.com/prometheus/common/version.BuildDate={{.Date}}
3838
3939
archives:
40-
- format: binary
40+
- formats:
41+
- binary
4142
allow_different_binary_count: true
4243

4344
checksum:
@@ -60,7 +61,8 @@ kos:
6061
- id: ko-image
6162
main: .
6263
base_image: cgr.dev/chainguard/static
63-
repository: ghcr.io/cpanato
64+
repositories:
65+
- ghcr.io/cpanato
6466
platforms:
6567
- all
6668
tags:
@@ -75,5 +77,8 @@ release:
7577
github:
7678
owner: cpanato
7779
name: github_actions_exporter
78-
draft: false
80+
# Keep the release as a draft so the pipeline can still add assets to it
81+
# (immutable releases forbid uploading assets once published). The release
82+
# workflow publishes it in its last job.
83+
draft: true
7984
prerelease: allow

0 commit comments

Comments
 (0)