Skip to content

Commit b21d4f0

Browse files
committed
ci: adjust ci/cd
1 parent cfe0c35 commit b21d4f0

File tree

2 files changed

+73
-11
lines changed

2 files changed

+73
-11
lines changed

.github/workflows/ci.yml

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,81 @@ jobs:
2222
uses: actions/setup-node@v4
2323
with:
2424
node-version: 18
25-
cache: 'yarn'
25+
cache: "yarn"
2626

2727
- name: Install dependencies
2828
run: yarn
2929

3030
- name: Build
3131
run: yarn build
32+
33+
choose-version:
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- name: Add version selection comment
38+
uses: actions/github-script@v6
39+
with:
40+
script: |
41+
github.rest.issues.createComment({
42+
issue_number: context.issue.number,
43+
owner: context.repo.owner,
44+
repo: context.repo.repo,
45+
body: `
46+
## Please select the version update for the package:
47+
- 👍 Patch
48+
- 🎉 Minor
49+
- 🚀 Major
50+
51+
React with the appropriate emoji to choose the version.
52+
`
53+
})
54+
55+
check-version:
56+
runs-on: ubuntu-latest
57+
needs: choose-version
58+
steps:
59+
- name: Check version bump reaction
60+
uses: actions/github-script@v6
61+
with:
62+
script: |
63+
const { data: reactions } = await github.rest.reactions.listForIssue({
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
issue_number: context.issue.number
67+
});
68+
69+
let versionType = 'patch'; // default
70+
reactions.forEach(reaction => {
71+
if (reaction.content === 'rocket') {
72+
versionType = 'major';
73+
} else if (reaction.content === 'tada') {
74+
versionType = 'minor';
75+
}
76+
});
77+
78+
console.log(`Version to bump: ${versionType}`);
79+
core.setOutput('version_type', versionType);
80+
81+
release:
82+
runs-on: ubuntu-latest
83+
needs: check-version
84+
steps:
85+
- name: Checkout code
86+
uses: actions/checkout@v3
87+
88+
- name: Setup Node.js
89+
uses: actions/setup-node@v3
90+
with:
91+
node-version: '18'
92+
registry-url: 'https://registry.npmjs.org/'
93+
94+
- name: Bump version
95+
run: |
96+
yarn version --${{ needs.check-version.outputs.version_type }}
97+
98+
- name: Push changes and tags
99+
run: |
100+
git config user.email "[email protected]"
101+
git config user.name "vtexgithubbot"
102+
git push --follow-tags

.github/workflows/release.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,7 @@ jobs:
3636
- name: Build
3737
run: yarn build
3838

39-
- name: Update version to patch
40-
run: yarn version --patch
41-
4239
- name: Publish
4340
run: yarn publish --non-interactive
4441
env:
45-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
46-
47-
- name: Push changes and tags
48-
run: |
49-
git config user.email "[email protected]"
50-
git config user.name "vtexgithubbot"
51-
git push --follow-tags
42+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)