11name : Release
22
3- # Fires ONLY when you push a version tag like v1.0.6.
4- # Runs tests → builds Win/Mac/Linux binaries → publishes to npm + GPR →
5- # creates a GitHub Release with all assets + checksums.
6- # You NEVER need to run `npm publish` locally.
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)
78
89on :
910 push :
10- tags :
11- - ' v[0-9]+.[0-9]+.[0-9]+'
11+ branches : [ main ]
1212 workflow_dispatch :
1313
14+ permissions :
15+ contents : write
16+ packages : write
17+
1418jobs :
15- # ──────────────────────────────────────────────
16- # 1. GATE: tests must pass before anything else
17- # ──────────────────────────────────────────────
19+ # ═══════════════════════════════════════════════════════════
20+ # 1. AUTO-VERSION — CalVer: YYYY.M.BUILD, auto-increments
21+ # ═══════════════════════════════════════════════════════════
22+ version :
23+ name : Calculate Version
24+ runs-on : ubuntu-latest
25+ outputs :
26+ version : ${{ steps.calver.outputs.version }}
27+ tag : ${{ steps.calver.outputs.tag }}
28+ steps :
29+ - uses : actions/checkout@v4
30+ with :
31+ fetch-depth : 0
32+ fetch-tags : true
33+
34+ - name : Generate CalVer
35+ id : calver
36+ run : |
37+ YEAR=$(date +%Y)
38+ MONTH=$(date +%-m)
39+ 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
44+ done
45+ NEXT=$((HIGHEST + 1))
46+ V="${YEAR}.${MONTH}.${NEXT}"
47+ echo "version=${V}" >> $GITHUB_OUTPUT
48+ echo "tag=v${V}" >> $GITHUB_OUTPUT
49+ echo "CalVer: ${V} (tag: v${V})"
50+
51+ # ═══════════════════════════════════════════════════════════
52+ # 2. TEST — must pass on all Node versions
53+ # ═══════════════════════════════════════════════════════════
1854 test :
19- name : Test gate
55+ name : Test (Node ${{ matrix.node }})
2056 runs-on : ubuntu-latest
57+ needs : [ version ]
2158 defaults : { run: { working-directory: ./cloudsync-cli } }
2259 strategy :
2360 matrix :
3269 - run : npm ci
3370 - run : npm test
3471
35- # ──────────────────────────────────────────────
36- # 2 . BUILD platform binaries (parallel)
37- # ──────────────────────────────────────────────
72+ # ═══════════════════════════════════════════════════════════
73+ # 3 . BUILD — platform binaries (parallel)
74+ # ═══════════════════════════════════════════════════════════
3875 build-windows :
3976 name : Windows EXE
4077 runs-on : windows-latest
70107 retention-days : 7
71108
72109 build-linux :
73- name : Linux binary
110+ name : Linux Binary
74111 runs-on : ubuntu-latest
75112 needs : [ test ]
76113 defaults : { run: { working-directory: ./cloudsync-cli } }
92129 retention-days : 7
93130
94131 build-macos :
95- name : macOS binary
132+ name : macOS Binary
96133 runs-on : macos-latest
97134 needs : [ test ]
98135 defaults : { run: { working-directory: ./cloudsync-cli } }
@@ -113,35 +150,67 @@ jobs:
113150 path : cloudsync-cli/cloudsync
114151 retention-days : 7
115152
116- # ──────────────────────────────────────────────
117- # 3. CREATE GITHUB RELEASE with all binaries
118- # ──────────────────────────────────────────────
119- github-release :
120- name : GitHub Release
153+ # ═══════════════════════════════════════════════════════════
154+ # 4. PUBLISH EVERYTHING (npm + GPR + Git tag + GitHub Release)
155+ # ═══════════════════════════════════════════════════════════
156+ publish :
157+ name : Publish & Release
121158 runs-on : ubuntu-latest
122- needs : [ build-windows, build-linux, build-macos ]
123- permissions :
124- contents : write
159+ needs : [ version, build-windows, build-linux, build-macos ]
160+ defaults : { run: { working-directory: ./cloudsync-cli } }
125161 steps :
126162 - uses : actions/checkout@v4
163+ with :
164+ fetch-depth : 0
165+ fetch-tags : true
166+
127167 - uses : actions/download-artifact@v4
128168 with : { name: windows-build, path: assets/windows }
129169 - uses : actions/download-artifact@v4
130170 with : { name: linux-build, path: assets/linux }
131171 - uses : actions/download-artifact@v4
132172 with : { name: macos-build, path: assets/macos }
133173
174+ - name : Set version in package.json
175+ run : npm pkg set version=${{ needs.version.outputs.version }}
176+
177+ - name : Create and push git tag
178+ run : |
179+ git config user.name "github-actions"
180+ git config user.email "actions@github.com"
181+ git tag ${{ needs.version.outputs.tag }}
182+ git push origin ${{ needs.version.outputs.tag }}
183+
184+ - uses : actions/setup-node@v4
185+ with :
186+ node-version : ' 20'
187+ registry-url : ' https://registry.npmjs.org'
188+ cache : npm
189+ cache-dependency-path : cloudsync-cli/package-lock.json
190+ - run : npm ci
191+ - run : npm publish --access public
192+ env :
193+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
194+
195+ - name : Publish to GitHub Packages
196+ run : |
197+ npm pkg set name="@tech4file/cloudsync-cli"
198+ npm publish --access public
199+ env :
200+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
201+
134202 - name : Generate checksums
135203 run : |
136204 cd assets
137205 find . -type f ! -name '*.zip' ! -name '*.bat' ! -name '*.iss' ! -name '*.md' ! -name 'LICENSE' \
138206 -exec sha256sum {} \; > checksums.txt
139207 cat checksums.txt
140208
141- - name : Create Release
209+ - name : Create GitHub Release
142210 uses : softprops/action-gh-release@v1
143211 with :
144- name : CloudSync-CLI ${{ github.ref_name }}
212+ tag_name : ${{ needs.version.outputs.tag }}
213+ name : ${{ needs.version.outputs.version }}
145214 generate_release_notes : true
146215 files : |
147216 assets/windows/cloudsync.exe
@@ -153,55 +222,3 @@ jobs:
153222 assets/checksums.txt
154223 env :
155224 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
156-
157- # ──────────────────────────────────────────────
158- # 4. PUBLISH TO NPM
159- # ──────────────────────────────────────────────
160- publish-npm :
161- name : npm publish
162- runs-on : ubuntu-latest
163- needs : [ test ]
164- defaults : { run: { working-directory: ./cloudsync-cli } }
165- steps :
166- - uses : actions/checkout@v4
167- - uses : actions/setup-node@v4
168- with :
169- node-version : ' 20'
170- registry-url : ' https://registry.npmjs.org'
171- cache : npm
172- cache-dependency-path : cloudsync-cli/package-lock.json
173- - name : Set version from tag
174- run : npm pkg set version=${GITHUB_REF_NAME#v}
175- - run : npm ci
176- - run : npm publish --access public
177- env :
178- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
179-
180- # ──────────────────────────────────────────────
181- # 5. PUBLISH TO GITHUB PACKAGES
182- # ──────────────────────────────────────────────
183- publish-gpr :
184- name : GitHub Packages publish
185- runs-on : ubuntu-latest
186- needs : [ test ]
187- defaults : { run: { working-directory: ./cloudsync-cli } }
188- permissions :
189- contents : read
190- packages : write
191- steps :
192- - uses : actions/checkout@v4
193- - uses : actions/setup-node@v4
194- with :
195- node-version : ' 20'
196- registry-url : ' https://npm.pkg.github.com'
197- scope : ' @tech4file'
198- cache : npm
199- cache-dependency-path : cloudsync-cli/package-lock.json
200- - name : Set version and scope
201- run : |
202- npm pkg set version=${GITHUB_REF_NAME#v}
203- npm pkg set name="@tech4file/cloudsync-cli"
204- - run : npm ci
205- - run : npm publish --access public
206- env :
207- NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments