Skip to content

Commit f49c91c

Browse files
committed
feat: add beta release workflow
1 parent 54aeda9 commit f49c91c

File tree

5 files changed

+104
-25
lines changed

5 files changed

+104
-25
lines changed

.github/workflows/beta-release.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Beta Release
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
beta_release:
8+
runs-on: ubuntu-latest
9+
env:
10+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
11+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
ref: ${{ github.head_ref }}
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: '16.x'
19+
registry-url: 'https://registry.npmjs.org'
20+
cache: 'yarn'
21+
22+
- name: Install dev dependencies
23+
run: yarn install
24+
25+
- name: Setup npm credentials file
26+
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> .npmrc
27+
28+
- name: Setup git credentials
29+
run: |
30+
git config --global user.name 'Auto Release Bot'
31+
git config --global user.email 'auto-release-bot@users.noreply.github.com'
32+
33+
- name: Get current package.json version
34+
run: echo "PACKAGE_VERSION=$(npm pkg get version)" >> $GITHUB_ENV
35+
36+
- name: First beta release for this pull request
37+
if: contains(env.PACKAGE_VERSION, 'beta') == false
38+
run: echo "NEW_VERSION=$(npm version prerelease --no-git-tag-version --preid=beta.$GITHUB_PR_NUMBER)" >> $GITHUB_ENV
39+
env:
40+
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
41+
42+
- name: Subsequent beta releases for this pull request
43+
if: contains(env.PACKAGE_VERSION, 'beta')
44+
run: echo "NEW_VERSION=$(npm version prerelease --no-git-tag-version --preid=beta)" >> $GITHUB_ENV
45+
env:
46+
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
47+
48+
- name: Release a new beta version
49+
run: npm publish --tag beta
50+
env:
51+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
52+
53+
- name: Save new release version
54+
run: |
55+
git add ./package.json
56+
git commit -m "chore: bump version to $NEW_VERSION"
57+
git push
58+
59+
- uses: actions/github-script@v6
60+
with:
61+
script: |
62+
github.rest.issues.createComment({
63+
issue_number: context.issue.number,
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
body: `Beta version released with the last commit 🚀
67+
68+
\`\`\`
69+
yarn add react-tooltip@${{ env.NEW_VERSION }}
70+
\`\`\`
71+
or
72+
\`\`\`
73+
npm install react-tooltip@${{ env.NEW_VERSION }}
74+
\`\`\`
75+
`
76+
})

.github/workflows/bundlesize.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run Bundlesize
1+
name: Bundlesize
22

33
on:
44
workflow_call:
@@ -7,8 +7,8 @@ jobs:
77
bundlesize:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions/setup-node@v3
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-node@v4
1212

1313
- name: Install dev dependencies
1414
run: yarn install
@@ -18,4 +18,3 @@ jobs:
1818

1919
- name: Bundlesize
2020
run: yarn run bundlesize
21-

.github/workflows/lint.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run basic linting and testing
1+
name: Lint
22

33
on:
44
workflow_call:
@@ -7,8 +7,8 @@ jobs:
77
lint:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions/setup-node@v3
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-node@v4
1212

1313
- name: Install dev dependencies
1414
run: yarn install
@@ -20,11 +20,11 @@ jobs:
2020
needs: lint
2121
strategy:
2222
matrix:
23-
version: [16, 18]
23+
version: [16, 18, 20]
2424
runs-on: ubuntu-latest
2525
steps:
26-
- uses: actions/checkout@v2
27-
- uses: actions/setup-node@v3
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-node@v4
2828
with:
2929
node-version: ${{ matrix.version }}
3030

.github/workflows/pull-request.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ jobs:
1616
if: 'github.event.pull_request.draft == false'
1717
uses: ./.github/workflows/bundlesize.yaml
1818

19+
beta_release:
20+
uses: ./.github/workflows/beta-release.yaml
21+
# allow the children job to have access to the secrets of the repository
22+
secrets: inherit
23+
1924
fail_if_pull_request_is_draft:
2025
if: github.event.pull_request.draft == true
2126
runs-on: ubuntu-18.04

.github/workflows/stale.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,26 @@ name: Mark stale issues and pull requests
77

88
on:
99
schedule:
10-
- cron: '00 12 * * *'
10+
- cron: '00 12 * * *'
1111

1212
jobs:
1313
stale:
14-
1514
runs-on: ubuntu-latest
1615
permissions:
1716
issues: write
1817
pull-requests: write
1918

2019
steps:
21-
- uses: actions/stale@v5
22-
with:
23-
repo-token: ${{ secrets.GITHUB_TOKEN }}
24-
days-before-issue-stale: 90
25-
days-before-issue-close: 30
26-
days-before-pr-stale: 90
27-
days-before-pr-close: 30
28-
stale-issue-message: 'This issue is stale because it has not seen activity in 30 days. Remove the `stale` label or comment within 14 days, or it will be closed.'
29-
stale-pr-message: 'This pull request is stale because it has not seen activity in 30 days. Remove the `stale` label or comment within 14 days, or it will be closed.'
30-
stale-issue-label: 'stale'
31-
stale-pr-label: 'stale'
32-
exempt-issue-labels: 'help-wanted,v6'
33-
exempt-pr-labels: 'help-wanted,v6'
20+
- uses: actions/stale@v5
21+
with:
22+
repo-token: ${{ secrets.GITHUB_TOKEN }}
23+
days-before-issue-stale: 90
24+
days-before-issue-close: 30
25+
days-before-pr-stale: 90
26+
days-before-pr-close: 30
27+
stale-issue-message: 'This issue is stale because it has not seen activity in 30 days. Remove the `stale` label or comment within 14 days, or it will be closed.'
28+
stale-pr-message: 'This pull request is stale because it has not seen activity in 30 days. Remove the `stale` label or comment within 14 days, or it will be closed.'
29+
stale-issue-label: 'stale'
30+
stale-pr-label: 'stale'
31+
exempt-issue-labels: 'help-wanted,v6'
32+
exempt-pr-labels: 'help-wanted,v6'

0 commit comments

Comments
 (0)