Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Release Workflow #40

Merged
merged 2 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading