Repository navigation
112 lines (112 loc) · 3.94 KB
/
Copy pathrelease.yaml
File metadata and controls
112 lines (112 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Release
on:
push:
tags: ["v*"]
permissions: {}
concurrency:
group: release
cancel-in-progress: false
jobs:
build:
permissions:
contents: read
runs-on: ubuntu-26.04
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
platform:
- os: linux
arch: arm64
- os: linux
arch: amd64
- os: darwin
arch: arm64
- os: darwin
arch: amd64
env:
BINARY: constable
TAG: ${{ github.ref_name }}
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Install mise
uses: jdx/mise-action@6612f0ef07ed2a736cd1e00a94a065522dd41195 # v5.2.5
with:
version: 2026.10.25
# A cache from a pull request could reach the published artifacts.
cache: false
- name: Build
env:
GOOS: ${{ matrix.platform.os }}
GOARCH: ${{ matrix.platform.arch }}
run: |
# The archive name carries the version; the binary inside keeps the
# stable name that users and installers put on PATH.
CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=${TAG}" -o "$BINARY" ./cmd/constable
tar -czf "${BINARY}_${TAG}_${GOOS}_${GOARCH}.tar.gz" "$BINARY"
- name: Upload
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ${{ matrix.platform.os }}-${{ matrix.platform.arch }}
path: ${{ env.BINARY }}_${{ env.TAG }}_${{ matrix.platform.os }}_${{ matrix.platform.arch }}.tar.gz
if-no-files-found: error
publish:
needs: build
permissions:
attestations: write
contents: write
id-token: write
runs-on: ubuntu-26.04
timeout-minutes: 10
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
steps:
- name: Generate a token
id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ vars.APP_CLIENT_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
permission-contents: write
- name: Download the artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
path: dist
merge-multiple: true
- name: Make the checksums
run: cd dist && sha256sum -- *.tar.gz > checksums.txt
- name: Read the release state
id: state
run: |
if state="$(gh release view "$TAG" --json isDraft --jq '.isDraft' 2>/dev/null)"; then
if [[ "$state" == "true" ]]; then state=draft; else state=published; fi
else
state=none
fi
echo "state=$state" >> "$GITHUB_OUTPUT"
- name: Create a draft release
if: steps.state.outputs.state == 'none'
run: gh release create "$TAG" --verify-tag --draft --generate-notes --title "$TAG"
- name: Upload the assets
run: gh release upload "$TAG" dist/* --clobber
# The checksums say the files did not change in transit; the packslip
# records the executable inside each archive and signs every digest
# with this workflow's identity. See https://packslip.dev.
- name: Publish the packslip
uses: jdx/packslip@e0340e0c1d10c90a434de2b90f3a1ba345923564 # v1.11.4
with:
artifacts: dist/*.tar.gz
bin: constable
# GITHUB_TOKEN starts no workflow run, so the app token publishes the
# release and starts the tap update.
- name: Publish the release
if: steps.state.outputs.state != 'published'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: gh release edit "$TAG" --draft=false --latest