diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5e6afd3 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/.github/workflows/webpack.yml b/.github/workflows/webpack.yml index ba06062..1dec744 100644 --- a/.github/workflows/webpack.yml +++ b/.github/workflows/webpack.yml @@ -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: | @@ -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: | @@ -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: | diff --git a/package.json b/package.json index 2dc36fb..3bf0244 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/static/manifest.json b/static/manifest.json index d024cfe..c8a3193 100644 --- a/static/manifest.json +++ b/static/manifest.json @@ -40,4 +40,4 @@ "service_worker": "background.bundle.js" }, "offline_enabled": true -} +} \ No newline at end of file diff --git a/tools/release.js b/tools/update-version.js similarity index 56% rename from tools/release.js rename to tools/update-version.js index 9d4c596..a2fec98 100644 --- a/tools/release.js +++ b/tools/update-version.js @@ -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');