From 1b135e05cb7b12de50fdce5a723c27d4d26e395b Mon Sep 17 00:00:00 2001 From: Andy Young Date: Thu, 17 Aug 2023 00:20:01 -1000 Subject: [PATCH] feat: add automated release workflow (#177) * 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 * 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 d65c5bdf06257493043daccdd9e9eeb94a7567bb. * Try new prettier options * Bumps Version to v21.0.0 * Revert "Bumps Version to v21.0.0" This reverts commit 88ba22121f651ee0a1736ace4b087ac0b121a81d. * 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 Co-authored-by: GitHub Action Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 38 ++++++++++++++++++++++++++ .github/workflows/upgrade.yml | 50 +++++++++++++++++++++++++++++++++++ .lintignore | 2 -- package-lock.json | 24 +++++++++++------ scripts/version-check.sh | 27 +++++++++++++++++++ webpack.config.js | 2 +- 6 files changed, 132 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/upgrade.yml create mode 100755 scripts/version-check.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..8d259a90 --- /dev/null +++ b/.github/workflows/release.yml @@ -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/action-automatic-releases@v1.2.1" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: false + files: | + extension-chrome.zip + extension-firefox.zip \ No newline at end of file diff --git a/.github/workflows/upgrade.yml b/.github/workflows/upgrade.yml new file mode 100644 index 00000000..af6b68f5 --- /dev/null +++ b/.github/workflows/upgrade.yml @@ -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/github-push-action@v0.6.0 + with: + github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + branch: ${{ github.ref }} \ No newline at end of file diff --git a/.lintignore b/.lintignore index a9dc1bc7..fe351abc 100644 --- a/.lintignore +++ b/.lintignore @@ -2,5 +2,3 @@ node_modules/ dist/ webpack.config.js .idea/ -package.json -package-lock.json diff --git a/package-lock.json b/package-lock.json index f8f8f8a8..4c05dbfd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4287,7 +4287,8 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz", "integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==", - "dev": true + "dev": true, + "requires": {} }, "@webpack-cli/info": { "version": "1.5.0", @@ -4302,7 +4303,8 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz", "integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==", - "dev": true + "dev": true, + "requires": {} }, "@xtuc/ieee754": { "version": "1.2.0", @@ -4326,13 +4328,15 @@ "version": "1.8.0", "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz", "integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==", - "dev": true + "dev": true, + "requires": {} }, "acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true + "dev": true, + "requires": {} }, "ajv": { "version": "6.12.6", @@ -4379,7 +4383,8 @@ "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true + "dev": true, + "requires": {} }, "ansi-regex": { "version": "5.0.1", @@ -4898,7 +4903,8 @@ "version": "8.5.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz", "integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==", - "dev": true + "dev": true, + "requires": {} }, "eslint-scope": { "version": "5.1.1", @@ -5251,7 +5257,8 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", - "dev": true + "dev": true, + "requires": {} }, "ignore": { "version": "5.2.0", @@ -5834,7 +5841,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz", "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==", - "dev": true + "dev": true, + "requires": {} }, "postcss-modules-local-by-default": { "version": "4.0.0", diff --git a/scripts/version-check.sh b/scripts/version-check.sh new file mode 100755 index 00000000..d963b121 --- /dev/null +++ b/scripts/version-check.sh @@ -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 \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index aea5bba3..1fcf7d7e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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'),