Skip to content

Commit 74b57fc

Browse files
committed
ci: fix release pipeline
1 parent e9446c7 commit 74b57fc

File tree

2 files changed

+39
-70
lines changed

2 files changed

+39
-70
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919

20+
- name: Set Start Time
21+
id: set-time
22+
run: echo "start-time=$(date +%s)" >> $GITHUB_OUTPUT
23+
24+
2025
- name: Cache Cargo
2126
uses: actions/cache@v4
2227
id: cargo-cache
@@ -58,6 +63,7 @@ jobs:
5863
new-release-published: ${{ steps.get-next-version.outputs.new-release-published }}
5964
new-release-version: ${{ steps.get-next-version.outputs.new-release-version }}
6065
new-release-git-tag: ${{ steps.get-next-version.outputs.new-release-git-tag }}
66+
start-time: ${{ steps.set-time.outputs.start-time }}
6167

6268
build:
6369
name: Build ${{ matrix.target }}
@@ -179,10 +185,14 @@ jobs:
179185
uses: actions/checkout@v4
180186
with:
181187
fetch-depth: 0
188+
persist-credentials: true
182189

183190
- name: Setup Git
184191
run: |
185192
git pull
193+
git fetch --tags --force
194+
git config --global user.name 'github-actions[bot]'
195+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
186196
187197
- name: Cache Cargo
188198
uses: actions/cache@v4
@@ -213,6 +223,7 @@ jobs:
213223
env:
214224
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
215225
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
226+
RELEASE_TIMESTAMP: ${{ needs.get-next-version.outputs.start-time }}
216227
run: |
217228
git pull
218229
npm install -g semantic-release
@@ -224,68 +235,6 @@ jobs:
224235
npm install -g semantic-release-export-data
225236
npx semantic-release --repository-url https://github.com/vyfor/cord.nvim
226237
227-
sync-server-version:
228-
name: Sync Server Version Metadata
229-
runs-on: ubuntu-latest
230-
if: needs.get-next-version.outputs.new-release-published == 'true'
231-
needs: [get-next-version, release, merge]
232-
steps:
233-
- name: Checkout
234-
uses: actions/checkout@v4
235-
with:
236-
fetch-depth: 0
237-
238-
- name: Setup Git
239-
run: |
240-
git pull
241-
242-
- name: Install semantic-release-cargo
243-
uses: taiki-e/install-action@v2
244-
with:
245-
tool: semantic-release-cargo@2
246-
247-
- name: Update version metadata
248-
env:
249-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
250-
run: |
251-
VERSION="${{ needs.get-next-version.outputs.new-release-version }}"
252-
253-
git config --global user.name 'github-actions[bot]'
254-
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
255-
256-
semantic-release-cargo prepare $VERSION
257-
git add Cargo.toml Cargo.lock
258-
259-
PREVIOUS_TAG=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`)
260-
261-
if [ -z "$PREVIOUS_TAG" ]; then
262-
echo "No previous tag found, assuming first release"
263-
changes="true"
264-
else
265-
changes=$(git diff --name-only ${PREVIOUS_TAG}..v${VERSION} -- src/)
266-
fi
267-
268-
if [ -n "$changes" ]; then
269-
API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/v${VERSION}"
270-
RESPONSE=$(curl -sS -H "Authorization: Bearer $GITHUB_TOKEN" "$API_URL")
271-
TIMESTAMP=$(echo "$RESPONSE" | jq -r '[.assets[].updated_at] | min | if . then fromdate else empty end')
272-
273-
if [ -z "$TIMESTAMP" ]; then
274-
echo "No release assets found for v${VERSION}"
275-
exit 1
276-
fi
277-
278-
echo "${VERSION}|${TIMESTAMP}" > .github/server-metadata.txt
279-
git add .github/server-metadata.txt
280-
fi
281-
282-
if git diff --cached --quiet; then
283-
echo "nothing to commit"
284-
else
285-
git commit -m "chore: release ${VERSION} [skip ci]"
286-
git push
287-
fi
288-
289238
luarocks:
290239
name: LuaRocks Publish
291240
runs-on: ubuntu-latest

.releaserc.js

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,45 @@ module.exports = {
3131
}
3232
],
3333
[
34-
"@semantic-release/github",
34+
"@semantic-release/exec",
3535
{
36-
"assets": "dist/*",
37-
"successComment": false,
38-
"failComment": false
36+
"verifyConditionsCmd": "semantic-release-cargo verify-conditions",
37+
"prepareCmd": `
38+
semantic-release-cargo prepare \${nextRelease.version}
39+
40+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
41+
if [ -n "$PREVIOUS_TAG" ] && git diff --quiet "$PREVIOUS_TAG" HEAD -- src/; then
42+
echo "skipping metadata update"
43+
if [ -f .github/server-metadata.txt ]; then
44+
OLD_TS=$(cut -d'|' -f2 .github/server-metadata.txt)
45+
echo "\${nextRelease.version}|$OLD_TS" > .github/server-metadata.txt
46+
echo "new metadata: \${nextRelease.version}|\${OLD_TS}"
47+
fi
48+
else
49+
echo "updating server metadata"
50+
echo "\${nextRelease.version}|\${process.env.RELEASE_TIMESTAMP}" > .github/server-metadata.txt
51+
fi
52+
`,
53+
"publishCmd": "semantic-release-cargo publish"
3954
}
4055
],
4156
[
4257
"@semantic-release/git",
4358
{
59+
"assets": [
60+
"Cargo.toml",
61+
"Cargo.lock",
62+
".github/server-metadata.txt"
63+
],
4464
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
4565
}
4666
],
4767
[
48-
"@semantic-release/exec",
68+
"@semantic-release/github",
4969
{
50-
"verifyConditionsCmd": "semantic-release-cargo verify-conditions",
51-
"prepareCmd": "semantic-release-cargo prepare ${nextRelease.version}",
52-
"publishCmd": "semantic-release-cargo publish"
70+
"assets": "dist/*",
71+
"successComment": false,
72+
"failComment": false
5373
}
5474
],
5575
"semantic-release-export-data"

0 commit comments

Comments
 (0)