-
Notifications
You must be signed in to change notification settings - Fork 57
162 lines (152 loc) · 5.16 KB
/
release.yaml
File metadata and controls
162 lines (152 loc) · 5.16 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. 0.6.1)'
required: true
type: string
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
ref: main
- name: Validate version.txt
run: |
if ! grep -q "${{ inputs.version }}" cmd/scip/version.txt; then
echo "::error::cmd/scip/version.txt doesn't match version ${{ inputs.version }}"
exit 1
fi
- name: Create and push tags
run: |
TAG="v${{ inputs.version }}"
BINDINGS_TAG="bindings/go/scip/$TAG"
for t in "$TAG" "$BINDINGS_TAG"; do
if git rev-parse "$t" &>/dev/null; then
if [ "$(git rev-parse "$t"^{})" != "$(git rev-parse HEAD)" ]; then
echo "::error::Tag $t exists but points to a different commit"
exit 1
fi
echo "Tag $t already exists at HEAD, skipping"
else
git tag "$t"
fi
done
git push origin "$TAG" "$BINDINGS_TAG" 2>/dev/null || echo "Tags already pushed"
- name: Create draft GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="v${{ inputs.version }}"
if gh release view "$TAG" &>/dev/null; then
DRAFT=$(gh release view "$TAG" --json isDraft -q '.isDraft')
if [ "$DRAFT" = "false" ]; then
echo "::error::Release $TAG is already published"
exit 1
fi
echo "Draft release $TAG already exists, skipping creation"
exit 0
fi
{
echo 'Download the CLI for your current platform using:'
echo ''
echo '```bash'
echo 'env \'
echo " TAG=\"$TAG\" \\"
echo ' OS="$(uname -s | tr '"'"'[:upper:]'"'"' '"'"'[:lower:]'"'"')" \'
echo ' ARCH="$(uname -m | sed -e '"'"'s/x86_64/amd64/'"'"')" \'
echo ' bash -c '"'"'curl -L "https://github.com/scip-code/scip/releases/download/$TAG/scip-$OS-$ARCH.tar.gz"'"'"' \'
echo '| tar xzf - scip'
echo '```'
} | gh release create "$TAG" --title "scip $TAG" --generate-notes --draft --notes-file -
release-crate:
needs: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: v${{ inputs.version }}
- uses: DeterminateSystems/nix-installer-action@v21
- uses: DeterminateSystems/magic-nix-cache-action@v13
- name: Publish crate
run: |
OUTPUT=$(nix develop -c cargo publish --token '${{ secrets.CRATES_TOKEN }}' 2>&1) && exit 0
if echo "$OUTPUT" | grep -q "already uploaded"; then
echo "Crate version already published, skipping"
else
echo "$OUTPUT"
exit 1
fi
working-directory: bindings/rust
build-go-binaries:
needs: publish
permissions:
contents: write
strategy:
matrix:
include:
- runner: ubuntu-latest
goos: linux
goarch: amd64
asset_name: scip-linux-amd64
- runner: ubuntu-latest
goos: linux
goarch: arm64
asset_name: scip-linux-arm64
- runner: macos-latest
goos: darwin
goarch: arm64
asset_name: scip-darwin-arm64
- runner: macos-latest
goos: darwin
goarch: amd64
asset_name: scip-darwin-amd64
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v6
with:
ref: v${{ inputs.version }}
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Build
env:
CGO_ENABLED: '0'
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOWORK: 'off'
run: go build -ldflags '-X main.Reproducible=true' -o scip ./cmd/scip
- name: Package
env:
ASSET: ${{ matrix.asset_name }}
run: |
tar czf "$ASSET.tar.gz" scip LICENSE
sha256sum "$ASSET.tar.gz" > "$ASSET.tar.gz.sha256" 2>/dev/null || \
shasum -a 256 "$ASSET.tar.gz" > "$ASSET.tar.gz.sha256"
- name: Upload release assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ASSET: ${{ matrix.asset_name }}
run: |
TAG="v${{ inputs.version }}"
DRAFT=$(gh release view "$TAG" --json isDraft -q '.isDraft')
if [ "$DRAFT" = "false" ]; then
echo "::error::Release $TAG is already published, refusing to upload"
exit 1
fi
gh release upload "$TAG" "$ASSET.tar.gz" "$ASSET.tar.gz.sha256" --clobber
finalize-release:
needs: [release-crate, build-go-binaries]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Mark release as non-draft
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release edit "v${{ inputs.version }}" --draft=false