Skip to content

Commit

Permalink
feat: add automated release workflow (#177)
Browse files Browse the repository at this point in the history
* Add release workflow

* Add version checking script

* Lmao

* Revert

* Test

* Test

* Woops

* Bumps Version to v3.2.1

* Add prettier

* Prettified Code!

* ???

* Prettified Code!

* Bumps Version to v3.3.0

* Add the real release

* Delete zip

* Bumps Version to v5.0.0

* Woops

* woooow

* Bumps Version to v6.0.0

* dam

* Bumps Version to v7.0.0

* Convert to pr

* Correct pr creation

* Bumps Version to v8.0.0

* ??

* Bumps Version to v9.0.0

* Bumps Version to v10.0.0 (#4)

Co-authored-by: GitHub Action <[email protected]>

* Revert

* Bumps Version to v12.0.0

* Add token

* Bumps Version to v14.0.0

* Change access token name

* Set prettier options

* Bumps Version to v15.0.0

* Wtf

* Bumps Version to v16.0.0

* ?

* Bumps Version to v17.0.0

* Test

* Bumps Version to v18.0.0

* Wtf

* Bumps Version to v19.0.0

* Final

* Add suggestions

* Remove relative path

* Bumps Version to v20.0.0

* Revert "Bumps Version to v20.0.0"

This reverts commit d65c5bd.

* Try new prettier options

* Bumps Version to v21.0.0

* Revert "Bumps Version to v21.0.0"

This reverts commit 88ba221.

* Revert changes

* Bumps Version to v22.0.0

* ???

* Bumps Version to v23.0.0

* lol

* Bumps Version to v24.0.0

* Lol

* Bumps Version to v25.0.0

* Hm

* Bumps Version to v26.0.0

* Wow

* Only format changed files

* Hardcode version

* Bumps Version to v30.0.0

* Bumps Version to v32.0.0

* Undo version update

---------

Co-authored-by: ayoung19 <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Aug 17, 2023
1 parent 8fadf4e commit 1b135e0
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 11 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Extension Release

on:
push:
tags:
- "v*"

jobs:
release:
runs-on: "ubuntu-latest"

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Build and compress
run: |
npm install
npm run build
zip -r extension-chrome.zip dist
rm -rf dist
npm run build_ff
zip -r extension-firefox.zip dist
- uses: "marvinpinto/[email protected]"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
extension-chrome.zip
extension-firefox.zip
50 changes: 50 additions & 0 deletions .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Extension Upgrade

on:
workflow_dispatch:
inputs:
version:
description: Version
required: true

jobs:
upgrade:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- name: Checkout Branch
uses: actions/checkout@v3
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Update manifest/package.json version
run: |
./scripts/version-check.sh
jq '.version = $ENV.VERSION' manifest.json > tmp && mv tmp manifest.json
jq '.version = $ENV.VERSION' package.json > tmp && mv tmp package.json
jq '.version = $ENV.VERSION | .packages."".version = $ENV.VERSION' package-lock.json > tmp && mv tmp package-lock.json
npm install
npx prettier --write manifest.json package.json package-lock.json
env:
VERSION: ${{ inputs.version }}

- name: Add and commit
uses: EndBug/add-and-commit@v9
with:
message: "Bumps Version to v${{ inputs.version }}"
tag: "v${{ inputs.version }}"

- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
branch: ${{ github.ref }}
2 changes: 0 additions & 2 deletions .lintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ node_modules/
dist/
webpack.config.js
.idea/
package.json
package-lock.json
24 changes: 16 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions scripts/version-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
CURRENT_VERSION=$(jq '.version' manifest.json | tr -d '"')
NEW_VERSION="$VERSION"

if ! echo "$CURRENT_VERSION" | grep -Eq '^[0-9]+.[0-9]+.[0-9]+$'; then
echo Error: Current version not in valid format
exit 1
fi

if ! echo "$NEW_VERSION" | grep -Eq '^[0-9]+.[0-9]+.[0-9]+$'; then
echo Error: New version not in valid format
exit 1
fi

IFS='.' read -ra CURR <<< "$CURRENT_VERSION"
IFS='.' read -ra NEW <<< "$NEW_VERSION"

for i in ${!NEW[*]}; do
if [ $((NEW[i])) -lt $((CURR[i])) ]; then
echo ERROR: New release version is less than current release version
exit 1
elif [ $((NEW[i])) -gt $((CURR[i])) ]; then
exit 0
fi
done

echo Error: Current and new version are equal
exit 1
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = (env) => {
getPathEntries('./src/lib/page_scripts/*.ts'),
getPathEntries('./src/lib/types/*.d.ts'),
getPathEntries('./src/background.ts'),
getPathEntries('./src/**/*.js')
getPathEntries('./src/**/*.js'),
),
output: {
path: path.join(__dirname, 'dist'),
Expand Down

0 comments on commit 1b135e0

Please sign in to comment.