Skip to content

Commit 397020d

Browse files
committed
chore: automate release
1 parent dd145f1 commit 397020d

File tree

9 files changed

+165
-33
lines changed

9 files changed

+165
-33
lines changed

.github/workflows/approve-merge.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Merge Release PR
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
7+
jobs:
8+
pr_approved:
9+
if: ${{ github.event.review.state == 'approved' && github.event.pull_request.base.ref == 'master' && github.event.pull_request.head.ref == 'next' }}
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Clone git repo
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Merge PR
18+
run: |
19+
git checkout master
20+
git merge --ff origin/next
21+
git push -u origin master
22+
- uses: peter-evans/repository-dispatch@v3
23+
with:
24+
event-type: release_master

.github/workflows/build.yaml

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
name: build
1+
name: Build
22

33
on: push
44

55
jobs:
66
build:
7-
runs-on: ubuntu-20.04
7+
runs-on: ubuntu-22.04
88
steps:
9-
- name: Checkout
10-
uses: actions/checkout@v2
9+
- uses: actions/checkout@v4
1110

12-
- name: Setup NodeJS
13-
uses: actions/setup-node@v1
11+
- uses: actions/setup-node@v4
1412
with:
15-
node-version: '20.8.0'
13+
node-version-file: '.nvmrc'
1614

1715
- name: Install Dependencies
1816
run: npm ci
@@ -21,29 +19,23 @@ jobs:
2119
run: npm run build
2220

2321
test:
24-
runs-on: ubuntu-20.04
22+
runs-on: ubuntu-22.04
2523
needs: build
2624
steps:
27-
- name: Checkout
28-
uses: actions/checkout@v2
25+
- uses: actions/checkout@v4
2926

30-
- name: Setup NodeJS
31-
uses: actions/setup-node@v1
27+
- uses: actions/setup-node@v4
3228
with:
33-
node-version: '20.8.0'
29+
node-version-file: '.nvmrc'
3430

35-
- name: Setup System
36-
uses: restorecommerce/setup-system-action@v1
37-
with:
38-
backing-only: true
31+
- uses: restorecommerce/setup-system-action@v1
3932

4033
- name: Install Dependencies
4134
run: npm ci
4235

4336
- name: Test
4437
run: npm run test && npm run lcov-report
4538

46-
- name: Coveralls
47-
uses: coverallsapp/github-action@master
39+
- uses: coverallsapp/github-action@master
4840
with:
4941
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pr-lint.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: "Lint PR"
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
permissions:
11+
pull-requests: read
12+
13+
jobs:
14+
lint:
15+
name: pr-lint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: amannn/action-semantic-pull-request@v5
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-pr.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Release PR
2+
3+
on:
4+
push:
5+
branches:
6+
- next
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
release_pr:
13+
permissions:
14+
issues: write
15+
pull-requests: write
16+
contents: write
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version-file: '.nvmrc'
26+
27+
- name: Install Dependencies
28+
run: npm clean-install
29+
30+
- name: Generate Changes
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
run: |
34+
set -ex
35+
echo '# Release Changes' > changes.md
36+
npx [email protected] -d -p '@semantic-release/release-notes-generator' -b next | grep -v semantic-release | tee -a changes.md
37+
printf '\n---\n\n### Approve this PR to release above packages!' >> changes.md
38+
- name: Create PR
39+
env:
40+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
run: |
42+
set -ex
43+
export PR_NUMBER=$(gh pr list -B master -H next --json number | jq -r '.[0].number')
44+
if [[ "$(git rev-parse origin/master)" == "$(git rev-parse origin/next)" ]]; then exit 0; fi
45+
if [[ "$PR_NUMBER" == "null" ]]; then gh pr create -B master -H next -t "chore: release" -F changes.md; fi
46+
if [[ "$PR_NUMBER" != "null" ]]; then gh pr edit $PR_NUMBER -F changes.md; fi

.github/workflows/release.yaml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
types: [release_master]
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
ref: master
19+
20+
- name: Setup NodeJS
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version-file: '.nvmrc'
24+
25+
- name: Install Dependencies
26+
run: npm clean-install
27+
28+
- name: Git Config
29+
run: |
30+
git config --global user.email "[email protected]"
31+
git config --global user.name "Restorecommerce Bot"
32+
33+
- name: Build
34+
run: npm run build --verbose
35+
36+
- name: NPM Token
37+
env:
38+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39+
run: |
40+
echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" > .npmrc
41+
42+
- name: Release
43+
run: npx publish --no-verify-access --no-private --conventional-commits --yes --loglevel debug
44+
45+
- name: Sync next branch
46+
run: |
47+
git checkout next
48+
git merge master
49+
git push -u origin next

.husky

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
5+
6+
if [ "$BRACH" = "main" ]
7+
then
8+
echo "committing directly to main is blocked"
9+
exit 1
10+
fi
11+
12+
./node_modules/.bin/commitlint -e $1

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.11.1

package-lock.json

+1-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@
6565
"build": "npm-run-all lint build:clean build:tsc"
6666
},
6767
"engines": {
68-
"node": ">= 18.8.0"
68+
"node": ">= 20.0.0"
6969
}
7070
}

0 commit comments

Comments
 (0)