1- name : Publish
1+ name : Deploy
22
33on :
44 push :
55 branches :
66 - master
7+ - feature-*
8+ - release-*
9+ - hotfix-*
710
811concurrency :
912 group : publish-${{ github.ref }}
1013 cancel-in-progress : true
1114
1215jobs :
16+ build :
17+ name : Build
18+ runs-on : ubuntu-latest
19+ steps :
20+ - name : Clone
21+ uses : actions/checkout@v3
22+ - name : Node
23+ uses : actions/setup-node@v3
24+ - name : Cache
25+ id : cache-nodemodules
26+ uses : actions/cache@v3
27+ with :
28+ path : node_modules
29+ key : packages-${{ hashFiles('yarn.lock') }}
30+ restore-keys : |
31+ packages-
32+ - name : Install
33+ run : yarn install
34+ - name : Lint
35+ run : yarn lint
36+ - name : Build
37+ run : yarn build
38+ - name : Upload Build Artifact
39+ uses : actions/upload-artifact@v4
40+ with :
41+ name : build-artifact
42+ path : ./
43+
1344 should-release :
45+ needs : [build]
1446 name : Should Release
1547 runs-on : ubuntu-latest
1648 steps :
1749 - name : Clone
1850 uses : actions/checkout@v4
1951 - name : Node
20- uses : actions/setup-node@v4
21- with :
22- node-version : 20
52+ uses : actions/setup-node@v3
2353 - name : Deps
2454 run : npm i -g semver
2555 - name : Run should-release
26- run : node ./scripts/should-release.js
56+ shell : bash
57+ run : scripts/should-release.sh package.json
2758 - name : Current Version
2859 id : current-version
29- run : echo 'CURRENT_VERSION ='$(node -p -e "require('./package.json').version") >> $GITHUB_OUTPUT
60+ run : echo 'current_version ='$(node -p -e "require('./package.json').version") >> $GITHUB_OUTPUT
3061 - name : Check Skip Release
3162 id : skip-release
32- run : echo 'SKIP ='$(cat .skip-release) >> $GITHUB_OUTPUT
63+ run : echo 'skip ='$(cat .skip-release) >> $GITHUB_OUTPUT
3364 outputs :
34- SKIP : ${{ steps.skip-release.outputs.SKIP }}
35- CURRENT_VERSION : ${{ steps.current-version.outputs.CURRENT_VERSION }}
36-
37- publish :
65+ skip : ${{ steps.skip-release.outputs.skip }}
66+ current_version : ${{ steps.current-version.outputs.current_version }}
67+
68+ release-candidate :
3869 needs : [should-release]
39- if : needs.should-release.outputs.SKIP != 'true'
70+ if : github.ref != 'refs/heads/master' && (startsWith(github.ref, 'refs/heads/feature-') || startsWith(github.ref, 'refs/heads/hotfix-') || startsWith(github.ref, 'refs/heads/release-'))
71+ name : Release Candidate
72+ runs-on : ubuntu-latest
73+ steps :
74+ - uses : actions/checkout@v4
75+ - name : Download Build Artifact
76+ uses : actions/download-artifact@v4
77+ with :
78+ name : build-artifact
79+ path : ./
80+ - name : Update package.json with RC version
81+ if : ${{ needs.should-release.outputs.skip != 'true' }}
82+ run : scripts/rc.sh package.json
83+ - name : Upload Updated Artifact
84+ if : ${{ needs.should-release.outputs.skip != 'true' }}
85+ uses : actions/upload-artifact@v4
86+ with :
87+ name : build-artifact
88+ path : ./
89+ overwrite : true
90+
91+ publish :
92+ needs : [should-release, release-candidate]
93+ if : github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/hotfix-') || startsWith(github.ref, 'refs/heads/release-')
4094 name : Publish
4195 runs-on : ubuntu-latest
96+ steps :
97+ - uses : actions/checkout@v4
98+ - id : npm-publish
99+ if : ${{ needs.should-release.outputs.skip != 'true' }}
100+ uses : ./.github/actions/npm-publish
101+ with :
102+ github-token : ${{ secrets.GITHUB_TOKEN }}
103+ version : ${{ needs.should-release.outputs.current_version }}
104+ npm-auth-token : ${{ secrets.NPM_AUTH_TOKEN }}
105+ path : .
106+
107+ create-tag :
108+ needs : [publish]
109+ if : github.ref == 'refs/heads/master'
110+ name : Create Tag
111+ runs-on : ubuntu-latest
42112 steps :
43113 - name : Clone
44114 uses : actions/checkout@v4
45- - name : Node
46- uses : actions/setup-node@v4
47115 with :
48- node-version : 20
49- - name : Cache Yarn
50- id : cache-nodemodules
51- uses : actions/cache@v4
116+ fetch-depth : 0
117+ - name : Semver
118+ id : semver
119+ uses : luanlmd/semver-composite-action@v1.0.0
52120 with :
53- path : node_modules
54- key : packages-${{ hashFiles('yarn.lock') }}
55- restore-keys : |
56- packages-
57- - name : Yarn
58- if : steps.cache-nodemodules.outputs.cache-hit != 'true'
59- run : yarn install --immutable
60- - name : Setup NPM Registry
61- run : echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}' > ~/.npmrc && npm config get registry && npm whoami
62- - name : Build
63- run : npm run build
64- - name : Publish
65- run : npm publish
66- - name : Check Skip Release
67- id : skip-release
68- run : echo 'SKIP='$(cat .skip-release) >> $GITHUB_OUTPUT
121+ repo-path : ${{ github.workspace }}
69122 - name : Create tag
70- uses : actions/github-script@v7
123+ env :
124+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
125+ run : |
126+ git tag ${{ steps.semver.outputs.version }}
127+ git push --tags
128+
129+ notify :
130+ needs : [build, should-release, release-candidate, publish, create-tag]
131+ if : always()
132+ name : Notify
133+ runs-on : ubuntu-latest
134+ steps :
135+ - name : Discord Message on Success
136+ if : ${{ needs.build.result != 'failure' && needs.should-release.result != 'failure' && needs.publish.result != 'failure' && needs.create-tag.result != 'failure'}}
137+ uses : vitorvmrs/discord-send-embed@0f0cb61f7ed052734cc11765a5b2c5d0a5c3d9c2
71138 with :
72- github-token : ${{ secrets.GITHUB_TOKEN }}
73- script : |
74- github.rest.git.createRef({
75- owner: context.repo.owner,
76- repo: context.repo.repo,
77- ref: "refs/tags/v${{ needs.should-release.outputs.CURRENT_VERSION }}",
78- sha: context.sha
79- })
80- outputs :
81- SKIP : ${{ steps.skip-release.outputs.SKIP }}
139+ webhook-url : ${{ secrets.PI_DISCORD_WEBHOOK }}
140+ title : " ${{ github.repository }}/${{ github.ref_name }}"
141+ url : " ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
142+ description : " 🫡 DEPLOYED / Linterzinhiúu =]"
143+ color : 65280
144+ footer-text : " ${{ github.sha }} - ${{ github.event.head_commit.message }}"
145+ - name : Discord Message on Failure
146+ if : ${{ needs.build.result == 'failure' || needs.should-release.result == 'failure' || needs.publish.result == 'failure' || needs.create-tag.result == 'failure' }}
147+ uses : vitorvmrs/discord-send-embed@0f0cb61f7ed052734cc11765a5b2c5d0a5c3d9c2
148+ with :
149+ webhook-url : ${{ secrets.PI_DISCORD_WEBHOOK }}
150+ title : " ${{ github.repository }}/${{ github.ref_name }}"
151+ url : " ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
152+ description : " ❌ FAILED / Deu ruim =["
153+ color : 16711680
154+ footer-text : " ${{ github.sha }} - ${{ github.event.head_commit.message }}"
155+
0 commit comments