-
Notifications
You must be signed in to change notification settings - Fork 1
189 lines (162 loc) · 6.8 KB
/
Copy pathrelease.yml
File metadata and controls
189 lines (162 loc) · 6.8 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
# Manually build and release artifacts instead of using tauri-actions
# Reasons:
# 1. Include OS name in output filenames (tauri-actions doesn't support this)
# 2. Publish portable .exe for Windows (unsupported by tauri-actions either)
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Version-Check:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check-tag.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Check version consistency
run: npm run version check
- name: Check Tag Version
id: check-tag
shell: bash
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
echo "Package version: $PKG_VERSION"
if [[ "${{ github.ref_type }}" == "tag" ]]; then
TAG_VERSION="${{ github.ref_name }}"
TAG_VERSION=${TAG_VERSION#v}
if [[ "$TAG_VERSION" != "$PKG_VERSION" ]]; then
echo "❌ Git tag version ($TAG_VERSION) does not match package version ($PKG_VERSION)"
exit 1
fi
echo "✅ Git tag version matches package version: $TAG_VERSION"
else
COMMIT_HASH=$(git rev-parse HEAD)
COMMIT_HASH=${COMMIT_HASH:0:6}
PKG_VERSION="$PKG_VERSION"-"$COMMIT_HASH"
echo "Not a tag, using package version with commit hash: $PKG_VERSION"
fi
# Set the version as output
echo "version=$PKG_VERSION" >> $GITHUB_OUTPUT
Build-and-Release:
needs: [Version-Check]
uses: ./.github/workflows/build.yml
with:
version: ${{ needs.Version-Check.outputs.version }}
upload_artifacts: true
secrets:
XMCL_CURSEFORGE_API_KEY: ${{ secrets.XMCL_CURSEFORGE_API_KEY }}
XMCL_OPENLIST_BASE_URL: ${{ secrets.XMCL_OPENLIST_BASE_URL }}
NEXT_PUBLIC_OPENLIST_BASE_URL: ${{ secrets.NEXT_PUBLIC_OPENLIST_BASE_URL }}
Create-Release:
needs: [Version-Check, Build-and-Release]
if: always() && needs.Build-and-Release.result == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download non-macOS artifacts
uses: actions/download-artifact@v4
with:
pattern: 'XMCL_${{ needs.Version-Check.outputs.version }}_*'
path: artifacts
merge-multiple: true
- name: Download signed macOS artifacts
if: needs.Code-Sign-macOS.result == 'success'
uses: actions/download-artifact@v4
with:
pattern: 'XMCL_${{ needs.Version-Check.outputs.version }}_macos_*_signed'
path: artifacts-signed
merge-multiple: true
- name: Organize release artifacts
env:
VERSION: ${{ needs.Version-Check.outputs.version }}
SIGNING_SUCCESS: ${{ needs.Code-Sign-macOS.result == 'success' }}
run: |
mkdir -p release-artifacts
# Copy non-macOS artifacts
find artifacts -name "XMCL_${{ env.VERSION }}_windows_*" -exec cp {} release-artifacts/ \;
find artifacts -name "XMCL_${{ env.VERSION }}_linux_*" -exec cp {} release-artifacts/ \;
# Copy macOS artifacts (signed if available, unsigned otherwise)
if [ "${{ env.SIGNING_SUCCESS }}" = "true" ] && [ -d artifacts-signed ]; then
echo "Using signed macOS artifacts"
# Copy signed macOS artifacts (rename to remove _signed suffix)
find artifacts-signed -name "XMCL_${{ env.VERSION }}_macos_*" -type f | while read file; do
basename=$(basename "$file")
# Remove _signed suffix before the file extension
newname=$(echo "$basename" | sed 's/_signed\./\./')
cp "$file" "release-artifacts/$newname"
done
else
echo "⚠️ WARNING: Using unsigned macOS artifacts (signing failed or was skipped)"
# Copy unsigned macOS artifacts
find artifacts -name "XMCL_${{ env.VERSION }}_macos_*" -exec cp {} release-artifacts/ \;
fi
echo "Final release artifacts:"
ls -la release-artifacts/
# Commented out: SJMC server deployment is not used in XMCL
# - name: Upload artifacts to remote server
# env:
# SJMC_SECRET_KEY: ${{ secrets.SJMC_DEPLOY_SECRET_KEY }}
# SJMC_DEPLOY_API: ${{ secrets.SJMC_DEPLOY_API }}
# SJMC_DEPLOY_PROJECT: ${{ secrets.SJMC_DEPLOY_PROJECT }}
# run: |
# bash scripts/release/upload_to_sjmc_server.sh
# shell: bash
- name: Generate Changelog
id: changelog
run: |
pip install requests packaging
python scripts/release/generate_changelog_draft.py > release-notes.md
# Add platform support notice
echo "" >> release-notes.md
echo "---" >> release-notes.md
echo "" >> release-notes.md
echo "**Platform Support:** This release provides builds for Windows and Linux only. macOS builds are not included due to the requirement of an Apple Developer account for code signing." >> release-notes.md
shell: bash
- name: Prepare release notes output
id: release-notes
run: |
{
echo 'body<<EOF'
cat release-notes.md
echo EOF
} >> $GITHUB_OUTPUT
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.Version-Check.outputs.version }}
run: |
RELEASE_TAG="${{ env.VERSION }}"
# Create the release
gh release create "$GITHUB_REF_NAME" \
--title "XMCL ${{ env.VERSION }}" \
--draft \
$PRERELEASE \
--notes-file release-notes.md \
./release-artifacts/*
- name: Publish Gitee Release
if: ${{ vars.GITEE_NAMESPACE != '' }}
uses: nicennnnnnnlee/action-gitee-release@master
with:
gitee_action: create_release
gitee_owner: ${{ vars.GITEE_NAMESPACE }}
gitee_repo: XMCL
gitee_token: ${{ secrets.GITEE_TOKEN }}
gitee_tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || format('v{0}', needs.Version-Check.outputs.version) }}
gitee_release_name: XMCL ${{ needs.Version-Check.outputs.version }}
gitee_release_body: ${{ steps.release-notes.outputs.body }}
gitee_target_commitish: ${{ github.sha }}
gitee_upload_retry_times: 3
gitee_files: |
release-artifacts/*