Skip to content

Commit

Permalink
Added Release Workflow (#40)
Browse files Browse the repository at this point in the history
* Added release workflow
  • Loading branch information
PsychoSanchez authored Nov 16, 2024
1 parent d5a726d commit f680b4c
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 10 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Release Flow

on:
push:
branches:
- main
workflow_dispatch:
inputs:
version_type:
type: choice
description: 'Version type'
options:
- patch
- minor
- major

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 23.1.0

- name: Install dependencies
run: npm install

- name: Bump version
run: |
VERSION_TYPE=${{ github.event.inputs.version_type }}
if [ "$VERSION_TYPE" == "patch" ]; then
NEW_VERSION=$(npm version patch -m "Release %s")
elif [ "$VERSION_TYPE" == "minor" ]; then
NEW_VERSION=$(npm version minor -m "Release %s")
elif [ "$VERSION_TYPE" == "major" ]; then
NEW_VERSION=$(npm version major -m "Release %s")
else
echo "Invalid version type: $VERSION_TYPE"
exit 1
fi
echo "New version: $NEW_VERSION"
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Stash updated files and update package.json
run: |
npm i
git add .
- name: Create release branch
run: |
git checkout -b release/$NEW_VERSION
git push origin release/$NEW_VERSION
- name: Create tags
run: |
git push --tags
- name: Create release PR
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: release/$NEW_VERSION
title: 'Release $NEW_VERSION'
body: 'This PR merges the release branch for version $NEW_VERSION into main. Please fill in the release notes.'
base: main
6 changes: 3 additions & 3 deletions .github/workflows/webpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 23
node-version: 23.1.0

- name: Lint
run: |
Expand All @@ -32,7 +32,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 23
node-version: 23.1.0

- name: Test
run: |
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 23
node-version: 23.1.0

- name: Build
run: |
Expand Down
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
"build": "npm test && npm run lint && npm run build:prod",
"build:prod": "webpack --mode=production",
"start": "webpack --mode=development --watch",
"release": "node ./tools/release.js",
"release:patch": "npm version patch",
"release:minor": "npm version minor",
"release:major": "npm version major",
"preversion": "npm test && npm run lint",
"version": "npm run release && git add .",
"postversion": "git push && git push --tags",
"version": "npm run update-version",
"update-version": "node ./tools/update-version.js",
"prettier:check": "prettier ./src --check --cache --ignore-path .gitignore",
"prettier:write": "prettier ./src --write --ignore-unknown --ignore-path .gitignore",
"storybook": "storybook dev -p 6006",
Expand Down
2 changes: 1 addition & 1 deletion static/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
"service_worker": "background.bundle.js"
},
"offline_enabled": true
}
}
7 changes: 7 additions & 0 deletions tools/release.js → tools/update-version.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import fs from 'fs';
import { createRequire } from 'module';
import { dirname } from 'path';
import { fileURLToPath } from 'url';

const require = createRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

// Update manifest.json to package.json version
const manifest = require(__dirname + '/../static/manifest.json');
Expand Down

0 comments on commit f680b4c

Please sign in to comment.