Skip to content

Commit 4c472f7

Browse files
authored
chore(ci): Create release action (#39)
* build(deps): Add `conventional-changelog-cli` and `conventional-recommended-bump` * WIP: release action * build(package.json): Make package private * chore(ci): Release ci * build(ci): Release to production brach
1 parent da865ca commit 4c472f7

File tree

3 files changed

+465
-0
lines changed

3 files changed

+465
-0
lines changed

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release to Production Branch
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
release:
11+
name: Release to `production` branch
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
ref: master
18+
fetch-depth: 0
19+
20+
- name: Use Node 20
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
- run: yarn install --production=false
25+
26+
- name: Configure git
27+
run: |
28+
git config user.name "github-actions[bot]"
29+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
30+
# user email for github-actions[bot] is found in https://api.github.com/users/github-actions%5Bbot%5D
31+
32+
- name: Bump version number
33+
id: new_version_number
34+
run: |
35+
export RECOMMENDED_BUMP="$(yarn -s conventional-recommended-bump -p angular)"
36+
echo "Recommended bump: $RECOMMENDED_BUMP"
37+
npm --commit-hooks=false --git-tag-version=false version $RECOMMENDED_BUMP
38+
export VERSION=$(jq -r '.version' package.json)
39+
echo "version=$(echo $VERSION)" >> $GITHUB_OUTPUT
40+
echo "New version: $VERSION"
41+
42+
- name: Generate Changelog (CHANGELOG.MD)
43+
id: changelog
44+
run: |
45+
yarn changelog
46+
git add CHANGELOG.md
47+
npm \
48+
--allow-same-version \
49+
--force \
50+
--message "build(deploy): Bump to v${{ steps.new_version_number.outputs.version }}" \
51+
version ${{ steps.new_version_number.outputs.version }}
52+
53+
- name: Generate latest changelog (CHANGELOG_LATEST.md)
54+
run: yarn changelog:latest
55+
56+
- name: Create Release
57+
uses: softprops/action-gh-release@v2
58+
with:
59+
body_path: CHANGELOG_LATEST.md
60+
draft: false
61+
prerelease: false
62+
generate_release_notes: false
63+
name: "v${{ steps.new_version_number.outputs.version }}"
64+
tag_name: "v${{ steps.new_version_number.outputs.version }}"
65+
66+
- name: Push to `production` branch
67+
run: |
68+
git checkout production
69+
git rebase master
70+
git push origin production

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "sg-lottery-scraper",
33
"version": "3.1.1",
4+
"private": true,
45
"exports": "./index.js",
56
"license": "MIT",
67
"author": "Amos Tan <[email protected]>",
@@ -13,6 +14,8 @@
1314
"@types/yargs": "^17.0.7",
1415
"@typescript-eslint/eslint-plugin": "^5.5.0",
1516
"@typescript-eslint/parser": "^5.5.0",
17+
"conventional-changelog-cli": "^5.0.0",
18+
"conventional-recommended-bump": "^11.0.0",
1619
"eslint": "^8.4.0",
1720
"eslint-config-prettier": "^8.3.0",
1821
"eslint-plugin-import": "^2.25.3",
@@ -33,6 +36,8 @@
3336
"scripts": {
3437
"start": "node dist/scrape.js",
3538
"firebase": "node dist/sendFirebase.js",
39+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1 -u",
40+
"changelog:latest": "conventional-changelog -p angular -i CHANGELOG_LATEST.md -s -r 2",
3641
"dev:scrape": "ts-node src/scrape.ts",
3742
"dev:firebase": "ts-node src/sendFirebase.ts",
3843
"build": "rm -Rf dist/ && tsc -outDir dist",

0 commit comments

Comments
 (0)