Merge branch 'main' of https://github.com/Tech4File/cloudsync-cli #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| # FULLY AUTOMATED — every push to main triggers the complete pipeline. | |
| # No manual tags. No `npm publish`. Nothing local. | |
| # | |
| # Push to main → CalVer auto-version → Tests → Builds → Publish + Release | |
| # Version: YYYY.M.BUILD (e.g. 2026.7.1, 2026.7.2, 2026.8.1) | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| # ═══════════════════════════════════════════════════════════ | |
| # 1. AUTO-VERSION — CalVer: YYYY.M.BUILD, auto-increments | |
| # ═══════════════════════════════════════════════════════════ | |
| version: | |
| name: Calculate Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.calver.outputs.version }} | |
| tag: ${{ steps.calver.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Generate CalVer | |
| id: calver | |
| run: | | |
| YEAR=$(date +%Y) | |
| MONTH=$(date +%-m) | |
| git fetch --tags 2>/dev/null || true | |
| HIGHEST=0 | |
| for tag in $(git tag -l "v${YEAR}.${MONTH}.*"); do | |
| B=$(echo "$tag" | sed "s/v${YEAR}.${MONTH}.//") | |
| if [ "$B" -gt "$HIGHEST" ] 2>/dev/null; then HIGHEST=$B; fi | |
| done | |
| NEXT=$((HIGHEST + 1)) | |
| V="${YEAR}.${MONTH}.${NEXT}" | |
| echo "version=${V}" >> $GITHUB_OUTPUT | |
| echo "tag=v${V}" >> $GITHUB_OUTPUT | |
| echo "CalVer: ${V} (tag: v${V})" | |
| # ═══════════════════════════════════════════════════════════ | |
| # 2. TEST — must pass on all Node versions | |
| # ═══════════════════════════════════════════════════════════ | |
| test: | |
| name: Test (Node ${{ matrix.node }}) | |
| runs-on: ubuntu-latest | |
| needs: [ version ] | |
| defaults: { run: { working-directory: ./cloudsync-cli } } | |
| strategy: | |
| matrix: | |
| node: ['18', '20', '22'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| cache: npm | |
| cache-dependency-path: cloudsync-cli/package-lock.json | |
| - run: npm ci | |
| - run: npm test | |
| # ═══════════════════════════════════════════════════════════ | |
| # 3. BUILD — platform binaries (parallel) | |
| # ═══════════════════════════════════════════════════════════ | |
| build-windows: | |
| name: Windows EXE | |
| runs-on: windows-latest | |
| needs: [ test ] | |
| defaults: { run: { working-directory: ./cloudsync-cli } } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: npm | |
| cache-dependency-path: cloudsync-cli/package-lock.json | |
| - run: npm ci | |
| - run: npm install -g pkg@5.8.1 | |
| - run: pkg bin/cloudsync.js -t node18-win-x64 -o cloudsync.exe | |
| - run: .\cloudsync.exe --version | |
| - run: | | |
| mkdir release-assets | |
| copy cloudsync.exe release-assets\ | |
| copy installer\CloudSync-Setup.bat release-assets\ | |
| copy installer\CloudSync.iss release-assets\ | |
| copy README.md release-assets\ | |
| copy LICENSE release-assets\ | |
| Compress-Archive -Path release-assets\* -DestinationPath cloudsync-windows-x64.zip | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-build | |
| path: | | |
| cloudsync-cli/cloudsync.exe | |
| cloudsync-cli/cloudsync-windows-x64.zip | |
| cloudsync-cli/installer/CloudSync-Setup.bat | |
| cloudsync-cli/installer/CloudSync.iss | |
| retention-days: 7 | |
| build-linux: | |
| name: Linux Binary | |
| runs-on: ubuntu-latest | |
| needs: [ test ] | |
| defaults: { run: { working-directory: ./cloudsync-cli } } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: npm | |
| cache-dependency-path: cloudsync-cli/package-lock.json | |
| - run: npm ci | |
| - run: npm install -g pkg@5.8.1 | |
| - run: pkg bin/cloudsync.js -t node18-linux-x64 -o cloudsync | |
| - run: chmod +x cloudsync && ./cloudsync --version | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: cloudsync-cli/cloudsync | |
| retention-days: 7 | |
| build-macos: | |
| name: macOS Binary | |
| runs-on: macos-latest | |
| needs: [ test ] | |
| defaults: { run: { working-directory: ./cloudsync-cli } } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: npm | |
| cache-dependency-path: cloudsync-cli/package-lock.json | |
| - run: npm ci | |
| - run: npm install -g pkg@5.8.1 | |
| - run: pkg bin/cloudsync.js -t node18-macos-x64 -o cloudsync | |
| - run: chmod +x cloudsync && ./cloudsync --version | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-build | |
| path: cloudsync-cli/cloudsync | |
| retention-days: 7 | |
| # ═══════════════════════════════════════════════════════════ | |
| # 4. PUBLISH EVERYTHING (npm + GPR + Git tag + GitHub Release) | |
| # ═══════════════════════════════════════════════════════════ | |
| publish: | |
| name: Publish & Release | |
| runs-on: ubuntu-latest | |
| needs: [ version, build-windows, build-linux, build-macos ] | |
| defaults: { run: { working-directory: ./cloudsync-cli } } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - uses: actions/download-artifact@v4 | |
| with: { name: windows-build, path: assets/windows } | |
| - uses: actions/download-artifact@v4 | |
| with: { name: linux-build, path: assets/linux } | |
| - uses: actions/download-artifact@v4 | |
| with: { name: macos-build, path: assets/macos } | |
| - name: Set version in package.json | |
| run: npm pkg set version=${{ needs.version.outputs.version }} | |
| - name: Create and push git tag | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "actions@github.com" | |
| git tag ${{ needs.version.outputs.tag }} | |
| git push origin ${{ needs.version.outputs.tag }} | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: npm | |
| cache-dependency-path: cloudsync-cli/package-lock.json | |
| - run: npm ci | |
| - run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish to GitHub Packages | |
| run: | | |
| npm pkg set name="@tech4file/cloudsync-cli" | |
| npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate checksums | |
| run: | | |
| cd assets | |
| find . -type f ! -name '*.zip' ! -name '*.bat' ! -name '*.iss' ! -name '*.md' ! -name 'LICENSE' \ | |
| -exec sha256sum {} \; > checksums.txt | |
| cat checksums.txt | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ needs.version.outputs.tag }} | |
| name: ${{ needs.version.outputs.version }} | |
| generate_release_notes: true | |
| files: | | |
| assets/windows/cloudsync.exe | |
| assets/windows/cloudsync-windows-x64.zip | |
| assets/windows/CloudSync-Setup.bat | |
| assets/windows/CloudSync.iss | |
| assets/linux/cloudsync | |
| assets/macos/cloudsync | |
| assets/checksums.txt | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |