-
Notifications
You must be signed in to change notification settings - Fork 0
221 lines (189 loc) · 6.53 KB
/
release.yml
File metadata and controls
221 lines (189 loc) · 6.53 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
name: Release
on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches:
- main
permissions:
contents: write
issues: write
pull-requests: write
jobs:
# Check that CI passed before proceeding
check-ci:
name: Check CI Status
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: CI passed
run: echo "CI workflow completed successfully"
release:
name: Semantic Release
runs-on: ubuntu-latest
needs: check-ci
steps:
- name: Check out code
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.23'
cache: true
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Install semantic-release
run: |
npm install -g \
semantic-release@23 \
@semantic-release/changelog@6 \
@semantic-release/git@10 \
@semantic-release/github@10 \
@semantic-release/exec@6 \
conventional-changelog-conventionalcommits@7
- name: Run semantic release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
run: npx semantic-release
# Go library release artifacts
go-release:
name: Go Release Artifacts
runs-on: ubuntu-latest
needs: release
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Check out code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.23'
- name: Get latest tag
id: get_tag
run: |
git fetch --tags
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
- name: Run tests one final time
run: go test -v ./...
- name: Verify module
run: |
go mod verify
go mod tidy
if [ -n "$(git status --porcelain go.mod go.sum)" ]; then
echo "go.mod or go.sum is not tidy"
exit 1
fi
- name: Build examples
run: |
cd examples/basic
go build -v -ldflags="-X 'github.com/xraph/farp.ProtocolVersion=${{ steps.get_tag.outputs.version }}'" -o farp-basic-example .
- name: Upload example binary
uses: actions/upload-artifact@v6
with:
name: go-example-binary
path: examples/basic/farp-basic-example
# Rust library release
rust-release:
name: Rust Release Artifacts
runs-on: ubuntu-latest
needs: release
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Check out code
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
- name: Check if Cargo.toml exists
id: check_cargo
run: |
if [ -f "farp-rust/Cargo.toml" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Set up Rust
if: steps.check_cargo.outputs.exists == 'true'
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
if: steps.check_cargo.outputs.exists == 'true'
uses: Swatinem/rust-cache@v2
with:
workspaces: farp-rust
- name: Get latest tag
if: steps.check_cargo.outputs.exists == 'true'
id: get_tag
run: |
git fetch --tags
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
- name: Verify Cargo.toml version matches tag
if: steps.check_cargo.outputs.exists == 'true'
working-directory: farp-rust
run: |
CARGO_VERSION=$(grep "^version" Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
TAG_VERSION="${{ steps.get_tag.outputs.version }}"
echo "Cargo.toml version: $CARGO_VERSION"
echo "Git tag version: $TAG_VERSION"
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
echo "ERROR: Version mismatch! Cargo.toml has $CARGO_VERSION but tag is $TAG_VERSION"
echo "The semantic-release process should have updated Cargo.toml to match."
exit 1
fi
- name: Build Rust library
if: steps.check_cargo.outputs.exists == 'true'
working-directory: farp-rust
run: cargo build --release --all-features
- name: Run tests
if: steps.check_cargo.outputs.exists == 'true'
working-directory: farp-rust
run: cargo test --release --all-features
- name: Build documentation
if: steps.check_cargo.outputs.exists == 'true'
working-directory: farp-rust
run: cargo doc --release --all-features --no-deps
- name: Check if crates.io token is available
id: check_token
if: steps.check_cargo.outputs.exists == 'true'
run: |
if [ -n "${{ secrets.CARGO_REGISTRY_TOKEN }}" ]; then
echo "available=true" >> $GITHUB_OUTPUT
else
echo "available=false" >> $GITHUB_OUTPUT
fi
- name: Publish to crates.io
if: steps.check_cargo.outputs.exists == 'true' && steps.check_token.outputs.available == 'true'
working-directory: farp-rust
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
echo "Publishing farp v${{ steps.get_tag.outputs.version }} to crates.io..."
cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --allow-dirty
continue-on-error: true
- name: Upload Rust library artifacts
if: steps.check_cargo.outputs.exists == 'true'
uses: actions/upload-artifact@v6
with:
name: rust-library
path: farp-rust/target/release/libfarp*
- name: Upload documentation artifacts
if: steps.check_cargo.outputs.exists == 'true'
uses: actions/upload-artifact@v6
with:
name: rust-docs
path: farp-rust/target/doc/