11name : Release
22
3- # FULLY AUTOMATED — every push to main triggers the complete pipeline.
4- # No manual tags. No `npm publish`. Nothing local.
5- #
6- # Push to main → CalVer auto-version → Tests → Builds → Publish + Release
7- # Version: YYYY.M.BUILD (e.g. 2026.7.1, 2026.7.2, 2026.8.1)
3+ # FULLY AUTOMATED — every push to main.
4+ # CalVer auto-version → Tests → esbuild bundle → pkg binary → Publish.
85
96on :
107 push :
@@ -16,9 +13,6 @@ permissions:
1613 packages : write
1714
1815jobs :
19- # ═══════════════════════════════════════════════════════════
20- # 1. AUTO-VERSION — CalVer: YYYY.M.BUILD, auto-increments
21- # ═══════════════════════════════════════════════════════════
2216 version :
2317 name : Calculate Version
2418 runs-on : ubuntu-latest
@@ -27,30 +21,22 @@ jobs:
2721 tag : ${{ steps.calver.outputs.tag }}
2822 steps :
2923 - uses : actions/checkout@v4
30- with :
31- fetch-depth : 0
32- fetch-tags : true
33-
34- - name : Generate CalVer
24+ with : { fetch-depth: 0, fetch-tags: true }
25+ - name : CalVer
3526 id : calver
3627 run : |
37- YEAR=$(date +%Y)
38- MONTH=$(date +%-m)
28+ Y=$(date +%Y); M=$(date +%-m)
3929 git fetch --tags 2>/dev/null || true
40- HIGHEST =0
41- for tag in $(git tag -l "v${YEAR }.${MONTH }.*"); do
42- B=$(echo "$tag " | sed "s/v${YEAR }.${MONTH }.//")
43- if [ "$B" -gt "$HIGHEST " ] 2>/dev/null; then HIGHEST =$B; fi
30+ H =0
31+ for t in $(git tag -l "v${Y }.${M }.*"); do
32+ B=$(echo "$t " | sed "s/v${Y }.${M }.//")
33+ [ "$B" -gt "$H " ] 2>/dev/null && H =$B
4434 done
45- NEXT=$((HIGHEST + 1))
46- V="${YEAR}.${MONTH}.${NEXT}"
35+ V="${Y}.${M}.$((H+1))"
4736 echo "version=${V}" >> $GITHUB_OUTPUT
4837 echo "tag=v${V}" >> $GITHUB_OUTPUT
49- echo "CalVer : ${V} (tag: v${V}) "
38+ echo "Version : ${V}"
5039
51- # ═══════════════════════════════════════════════════════════
52- # 2. TEST — must pass on all Node versions
53- # ═══════════════════════════════════════════════════════════
5440 test :
5541 name : Test (Node ${{ matrix.node }})
5642 runs-on : ubuntu-latest
6955 - run : npm ci
7056 - run : npm test
7157
72- # ═══════════════════════════════════════════════════════════
73- # 3. BUILD — platform binaries (parallel)
74- # ═══════════════════════════════════════════════════════════
7558 build-windows :
7659 name : Windows EXE
7760 runs-on : windows-latest
@@ -81,12 +64,13 @@ jobs:
8164 - uses : actions/checkout@v4
8265 - uses : actions/setup-node@v4
8366 with :
84- node-version : ' 20 '
67+ node-version : ' 22 '
8568 cache : npm
8669 cache-dependency-path : cloudsync-cli/package-lock.json
8770 - run : npm ci
88- - run : npm install -g pkg@5.8.1
89- - run : pkg bin/cloudsync.js -t node18-win-x64 -o cloudsync.exe
71+ - run : npm run build
72+ - run : npm install -g @yao-pkg/pkg
73+ - run : pkg dist/bundle.cjs -t node22-win-x64 -o cloudsync.exe
9074 - run : .\cloudsync.exe --version
9175 - run : |
9276 mkdir release-assets
@@ -115,12 +99,13 @@ jobs:
11599 - uses : actions/checkout@v4
116100 - uses : actions/setup-node@v4
117101 with :
118- node-version : ' 20 '
102+ node-version : ' 22 '
119103 cache : npm
120104 cache-dependency-path : cloudsync-cli/package-lock.json
121105 - run : npm ci
122- - run : npm install -g pkg@5.8.1
123- - run : pkg bin/cloudsync.js -t node18-linux-x64 -o cloudsync
106+ - run : npm run build
107+ - run : npm install -g @yao-pkg/pkg
108+ - run : pkg dist/bundle.cjs -t node22-linux-x64 -o cloudsync
124109 - run : chmod +x cloudsync && ./cloudsync --version
125110 - uses : actions/upload-artifact@v4
126111 with :
@@ -137,32 +122,28 @@ jobs:
137122 - uses : actions/checkout@v4
138123 - uses : actions/setup-node@v4
139124 with :
140- node-version : ' 20 '
125+ node-version : ' 22 '
141126 cache : npm
142127 cache-dependency-path : cloudsync-cli/package-lock.json
143128 - run : npm ci
144- - run : npm install -g pkg@5.8.1
145- - run : pkg bin/cloudsync.js -t node18-macos-x64 -o cloudsync
129+ - run : npm run build
130+ - run : npm install -g @yao-pkg/pkg
131+ - run : pkg dist/bundle.cjs -t node22-macos-x64 -o cloudsync
146132 - run : chmod +x cloudsync && ./cloudsync --version
147133 - uses : actions/upload-artifact@v4
148134 with :
149135 name : macos-build
150136 path : cloudsync-cli/cloudsync
151137 retention-days : 7
152138
153- # ═══════════════════════════════════════════════════════════
154- # 4. PUBLISH EVERYTHING (npm + GPR + Git tag + GitHub Release)
155- # ═══════════════════════════════════════════════════════════
156139 publish :
157140 name : Publish & Release
158141 runs-on : ubuntu-latest
159142 needs : [ version, build-windows, build-linux, build-macos ]
160143 defaults : { run: { working-directory: ./cloudsync-cli } }
161144 steps :
162145 - uses : actions/checkout@v4
163- with :
164- fetch-depth : 0
165- fetch-tags : true
146+ with : { fetch-depth: 0, fetch-tags: true }
166147
167148 - uses : actions/download-artifact@v4
168149 with : { name: windows-build, path: assets/windows }
@@ -171,19 +152,24 @@ jobs:
171152 - uses : actions/download-artifact@v4
172153 with : { name: macos-build, path: assets/macos }
173154
174- - name : Set version in package.json
175- run : npm pkg set version=${{ needs.version.outputs.version }}
155+ - name : Set version
156+ run : |
157+ V=${{ needs.version.outputs.version }}
158+ npm pkg set version=$V
159+ echo "export const VERSION = '$V';" > src/version.mjs
176160
177- - name : Create and push git tag
161+ - name : Create git tag
178162 run : |
179163 git config user.name "github-actions"
180164 git config user.email "actions@github.com"
165+ git add package.json src/version.mjs
166+ git commit -m "release: ${{ needs.version.outputs.version }}" || true
181167 git tag ${{ needs.version.outputs.tag }}
182- git push origin ${{ needs.version.outputs.tag }}
168+ git push origin HEAD:main ${{ needs.version.outputs.tag }}
183169
184170 - uses : actions/setup-node@v4
185171 with :
186- node-version : ' 20 '
172+ node-version : ' 22 '
187173 registry-url : ' https://registry.npmjs.org'
188174 cache : npm
189175 cache-dependency-path : cloudsync-cli/package-lock.json
@@ -192,22 +178,20 @@ jobs:
192178 env :
193179 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
194180
195- - name : Publish to GitHub Packages
181+ - name : Publish to GPR
196182 run : |
197183 npm pkg set name="@tech4file/cloudsync-cli"
198184 npm publish --access public
199185 env :
200186 NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
201187
202- - name : Generate checksums
188+ - name : Checksums
203189 run : |
204190 cd assets
205191 find . -type f ! -name '*.zip' ! -name '*.bat' ! -name '*.iss' ! -name '*.md' ! -name 'LICENSE' \
206192 -exec sha256sum {} \; > checksums.txt
207- cat checksums.txt
208193
209- - name : Create GitHub Release
210- uses : softprops/action-gh-release@v1
194+ - uses : softprops/action-gh-release@v1
211195 with :
212196 tag_name : ${{ needs.version.outputs.tag }}
213197 name : ${{ needs.version.outputs.version }}
0 commit comments