Skip to content

Commit c4d3e60

Browse files
committed
fix: workflow release
1 parent 693a371 commit c4d3e60

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

.github/workflows/theseus-release.yml

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
name: Release Modrinth App
1010
if: >-
1111
github.event.workflow_run.conclusion == 'success' &&
12+
github.event.workflow_run.event == 'push' &&
1213
startsWith(github.event.workflow_run.head_branch, 'v')
1314
runs-on: ubuntu-latest
1415

@@ -23,6 +24,25 @@ jobs:
2324
- name: 📥 Check out code
2425
uses: actions/checkout@v4
2526

27+
- name: 🔒 Verify ref is a tag
28+
env:
29+
GH_TOKEN: ${{ github.token }}
30+
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
31+
run: |
32+
tag_sha=$(gh api "repos/${{ github.repository }}/git/refs/tags/${VERSION_TAG}" --jq '.object.sha' 2>/dev/null || true)
33+
if [ -z "$tag_sha" ]; then
34+
echo "::error::${VERSION_TAG} is not a git tag in this repo"
35+
exit 1
36+
fi
37+
if [ "$tag_sha" != "$HEAD_SHA" ]; then
38+
commit_sha=$(gh api "repos/${{ github.repository }}/git/tags/${tag_sha}" --jq '.object.sha' 2>/dev/null || echo "$tag_sha")
39+
if [ "$commit_sha" != "$HEAD_SHA" ]; then
40+
echo "::error::Tag ${VERSION_TAG} (${commit_sha}) does not match build head_sha (${HEAD_SHA})"
41+
exit 1
42+
fi
43+
fi
44+
echo "Verified ${VERSION_TAG} is a tag pointing at ${HEAD_SHA}"
45+
2646
- name: 📥 Download Modrinth App artifacts
2747
uses: dawidd6/action-download-artifact@v11
2848
with:
@@ -32,12 +52,32 @@ jobs:
3252
branch: ${{ env.VERSION_TAG }}
3353
use_unzip: true
3454

55+
- name: 📝 Extract app changelog
56+
env:
57+
VERSION: ${{ env.VERSION_TAG }}
58+
run: |
59+
node <<'EOF'
60+
const fs = require('fs');
61+
const version = process.env.VERSION.replace(/^v/, '');
62+
const src = fs.readFileSync('packages/blog/changelog.ts', 'utf8');
63+
const escaped = version.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
64+
const re = new RegExp("product:\\s*'app',\\s*version:\\s*'" + escaped + "',\\s*body:\\s*`([\\s\\S]*?)`,\\s*\\}");
65+
const m = src.match(re);
66+
if (!m) {
67+
console.error(`No app changelog entry found for version ${version}`);
68+
process.exit(1);
69+
}
70+
fs.writeFileSync('release-notes.md', m[1]);
71+
console.log(`Extracted changelog for app ${version}:`);
72+
console.log(m[1]);
73+
EOF
74+
3575
- name: 🛠️ Generate version manifest
3676
run: |
3777
# Reference: https://tauri.app/plugin/updater/#server-support
3878
jq -nc \
3979
--arg versionTag "${VERSION_TAG#v}" \
40-
--arg releaseNotes "See the full changelog at https://modrinth.com/news/changelog" \
80+
--rawfile releaseNotes release-notes.md \
4181
--rawfile macOsAarch64UpdateArtifactSignature "${MACOS_UNIVERSAL_BUNDLE_ARTIFACT_NAME}/universal-apple-darwin/release/bundle/macos/Modrinth App.app.tar.gz.sig" \
4282
--rawfile macOsX64UpdateArtifactSignature "${MACOS_UNIVERSAL_BUNDLE_ARTIFACT_NAME}/universal-apple-darwin/release/bundle/macos/Modrinth App.app.tar.gz.sig" \
4383
--rawfile linuxX64UpdateArtifactSignature "${LINUX_X64_BUNDLE_ARTIFACT_NAME}/release/bundle/appimage/Modrinth App_${VERSION_TAG#v}_amd64.AppImage.tar.gz.sig" \
@@ -120,7 +160,7 @@ jobs:
120160
121161
gh release create "$VERSION_TAG" \
122162
--title "Modrinth App ${VERSION}" \
123-
--notes "See the full changelog at https://modrinth.com/news/changelog" \
163+
--notes-file release-notes.md \
124164
"${WINDOWS_X64_BUNDLE_ARTIFACT_NAME}/release/bundle/nsis/Modrinth App_${VERSION}_x64-setup.exe" \
125165
"${MACOS_UNIVERSAL_BUNDLE_ARTIFACT_NAME}/universal-apple-darwin/release/bundle/dmg/Modrinth App_${VERSION}_universal.dmg" \
126166
"${LINUX_X64_BUNDLE_ARTIFACT_NAME}/release/bundle/appimage/Modrinth App_${VERSION}_amd64.AppImage" \

0 commit comments

Comments
 (0)