Skip to content

Commit e5ec9b0

Browse files
chore: align configuration, workflows, README, and ignore rules with local improvements
1 parent da8f56d commit e5ec9b0

7 files changed

Lines changed: 462 additions & 545 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
name: CI
22

3-
# Runs on every push to main/develop and every pull request.
4-
# Tests across Node 18/20/22 + Windows + macOS.
5-
# No publishing — that happens automatically when you push a tag like v1.0.6.
3+
# PR check — fast feedback before merging to main.
4+
# The full release pipeline (tests + build + publish) runs on push to main via release.yml.
65

76
on:
8-
push:
9-
branches: [ main, develop ]
107
pull_request:
118
branches: [ main ]
129
workflow_dispatch:
1310

1411
jobs:
15-
test-ubuntu:
12+
test:
1613
name: Test (Node ${{ matrix.node }})
1714
runs-on: ubuntu-latest
1815
defaults: { run: { working-directory: ./cloudsync-cli } }
@@ -31,63 +28,3 @@ jobs:
3128
for f in $(find src -name '*.js'); do node --check "$f" || exit 1; done
3229
node --check bin/cloudsync.js || exit 1
3330
- run: npm test
34-
- run: |
35-
node bin/cloudsync.js --version
36-
node bin/cloudsync.js --help
37-
node bin/cloudsync.js doctor
38-
node bin/cloudsync.js init --host test.example.com --user ci --port 22 --force
39-
node bin/cloudsync.js status
40-
41-
test-windows:
42-
name: Test (Windows)
43-
runs-on: windows-latest
44-
defaults: { run: { working-directory: ./cloudsync-cli } }
45-
steps:
46-
- uses: actions/checkout@v4
47-
- uses: actions/setup-node@v4
48-
with:
49-
node-version: '20'
50-
cache: npm
51-
cache-dependency-path: cloudsync-cli/package-lock.json
52-
- run: npm ci
53-
- run: |
54-
Get-ChildItem -Path src -Recurse -Filter *.js | ForEach-Object { node --check $_.FullName }
55-
node --check bin/cloudsync.js
56-
- run: npm test
57-
- run: |
58-
node bin/cloudsync.js --version
59-
node bin/cloudsync.js --help
60-
node bin/cloudsync.js init --host test.example.com --user ci --port 22 --force
61-
node bin/cloudsync.js status
62-
63-
test-macos:
64-
name: Test (macOS)
65-
runs-on: macos-latest
66-
defaults: { run: { working-directory: ./cloudsync-cli } }
67-
steps:
68-
- uses: actions/checkout@v4
69-
- uses: actions/setup-node@v4
70-
with:
71-
node-version: '20'
72-
cache: npm
73-
cache-dependency-path: cloudsync-cli/package-lock.json
74-
- run: npm ci
75-
- run: |
76-
find src -name '*.js' -exec node --check {} \;
77-
node --check bin/cloudsync.js
78-
- run: npm test
79-
- run: |
80-
node bin/cloudsync.js --version
81-
node bin/cloudsync.js --help
82-
node bin/cloudsync.js doctor
83-
84-
security:
85-
name: Security Audit
86-
runs-on: ubuntu-latest
87-
defaults: { run: { working-directory: ./cloudsync-cli } }
88-
steps:
89-
- uses: actions/checkout@v4
90-
- uses: actions/setup-node@v4
91-
with: { node-version: '20' }
92-
- run: npm ci
93-
- run: npm audit --audit-level=high --omit=dev

.github/workflows/release.yml

Lines changed: 94 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,60 @@
11
name: 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

89
on:
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+
1418
jobs:
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:
@@ -32,9 +69,9 @@ jobs:
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
@@ -70,7 +107,7 @@ jobs:
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 } }
@@ -92,7 +129,7 @@ jobs:
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 }}

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,25 @@
44

55
# Build artifacts
66
*.tgz
7+
*.exe
78
dist/
89
build/
910

1011
# IDE
1112
.vscode/
1213
.idea/
1314

14-
# Environment files
15+
# Environment files (sensitive)
1516
.env
1617
.env.local
1718
.env.*.local
1819

1920
# OS files
2021
.DS_Store
2122
Thumbs.db
23+
24+
# Test artifacts
25+
test-workspace/
26+
test.env
27+
clone-test/
28+
playground/

0 commit comments

Comments
 (0)