44 push :
55 tags :
66 - ' v*.*.*'
7+ branches :
8+ - main
79
810permissions :
911 contents : write
12+ id-token : write
13+ packages : write
1014
1115jobs :
12- goreleaser :
16+ prerelease :
17+ name : Prerelease
1318 runs-on : ubuntu-latest
19+ if : github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
1420 steps :
1521 - name : Checkout
1622 uses : actions/checkout@v4
1723 with :
1824 fetch-depth : 0
1925
20- - name : Set up Go
21- uses : actions/setup-go@v5
26+ - name : Set up Node.js
27+ uses : actions/setup-node@v4
2228 with :
23- go-version : ' 1.23'
29+ node-version : ' 20'
30+ cache : ' npm'
31+ registry-url : ' https://registry.npmjs.org'
2432
25- - name : Run GoReleaser
26- uses : goreleaser/goreleaser-action@v6
33+ - name : Install dependencies
34+ run : npm ci
35+
36+ - name : Generate prerelease version
37+ id : version
38+ run : |
39+ CURRENT_VERSION=$(node -p "require('./package.json').version")
40+ COMMIT_SHA=${GITHUB_SHA::7}
41+ PRERELEASE_VERSION="${CURRENT_VERSION}-preview.${COMMIT_SHA}"
42+ echo "VERSION=${PRERELEASE_VERSION}" >> $GITHUB_OUTPUT
43+ echo "Generated prerelease version: ${PRERELEASE_VERSION}"
44+
45+ - name : Update package.json version
46+ run : npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version
47+
48+ - name : Build
49+ run : npm run build
50+
51+ - name : Publish prerelease to npm
52+ run : npm publish --tag preview --access public
53+ env :
54+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
55+
56+ - name : Set up Node.js for GitHub Packages
57+ uses : actions/setup-node@v4
2758 with :
28- distribution : goreleaser
29- version : ' ~> v2'
30- args : release --clean
59+ node-version : ' 20'
60+ registry-url : ' https://npm.pkg.github.com'
61+ scope : ' @captainsafia'
62+
63+ - name : Publish prerelease to GitHub Packages
64+ run : npm publish --tag preview --access public --provenance
3165 env :
32- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
66+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
67+
68+ release :
69+ name : Release
70+ runs-on : ubuntu-latest
71+ if : startsWith(github.ref, 'refs/tags/v')
72+ steps :
73+ - name : Checkout
74+ uses : actions/checkout@v4
75+ with :
76+ fetch-depth : 0
77+
78+ - name : Set up Node.js
79+ uses : actions/setup-node@v4
80+ with :
81+ node-version : ' 20'
82+ cache : ' npm'
83+ registry-url : ' https://registry.npmjs.org'
84+
85+ - name : Install dependencies
86+ run : npm ci
87+
88+ - name : Extract version from tag
89+ id : version
90+ run : echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
91+
92+ - name : Update package.json version
93+ run : npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version
94+
95+ - name : Build
96+ run : npm run build
97+
98+ - name : Publish to npm
99+ run : npm publish --provenance --access public
100+ env :
101+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
102+
103+ - name : Set up Node.js for GitHub Packages
104+ uses : actions/setup-node@v4
105+ with :
106+ node-version : ' 20'
107+ registry-url : ' https://npm.pkg.github.com'
108+ scope : ' @captainsafia'
109+
110+ - name : Publish to GitHub Packages
111+ run : npm publish
112+ env :
113+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
114+
115+ - name : Create GitHub Release
116+ uses : softprops/action-gh-release@v2
117+ env :
118+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
119+ with :
120+ tag_name : ${{ github.ref_name }}
121+ name : Release ${{ github.ref_name }}
122+ body : |
123+ ## Installation
124+
125+ ### From npm
126+ ```bash
127+ npm install -g @captainsafia/grove@${{ steps.version.outputs.VERSION }}
128+ ```
129+
130+ ### From GitHub Packages
131+ ```bash
132+ npm install -g @captainsafia/grove@${{ steps.version.outputs.VERSION }} --registry=https://npm.pkg.github.com
133+ ```
134+
135+ ## Changes
136+
137+ See the [commits](https://github.com/captainsafia/grove/compare/v${{ steps.version.outputs.VERSION }}...HEAD) for details.
138+ draft : false
139+ prerelease : false
0 commit comments