Skip to content

Commit

Permalink
Fix broken action based releases (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
notlmn authored Jan 2, 2023
1 parent 1b85b24 commit cc1972d
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 65 deletions.
130 changes: 71 additions & 59 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: Deployment
env:
DIRECTORY: distribution

# FILE GENERATED WITH: npx ghat fregante/ghatemplates/webext
# SOURCE: https://github.com/fregante/ghatemplates
# OPTIONS: {"exclude":["on.schedule"]}

name: Release
on:
workflow_dispatch: null
schedule:
- cron: '10 11 * * 1' # Every Monday at 11:10 https://crontab.guru/#10_11_*_*_1
push:
Expand All @@ -10,69 +17,74 @@ on:
- "22.*"
- "23.*"
- "24.*"

jobs:

Version:
outputs:
created: ${{ steps.daily-version.outputs.created }}
version: ${{ steps.daily-version.outputs.version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: fregante/setup-git-token@v1
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create tag if necessary
if: github.event_name == 'schedule'
run: |
git fetch --tags
if [[ $(git tag -l --points-at HEAD) = '' ]]; then
echo '::set-output name=created::yes'
export VER=$(npx daily-version)
git tag $VER -m $VER
git push origin $VER
fi
Build:
fetch-depth: 20
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- name: install
run: npm ci || npm install
- run: npm test
- uses: fregante/daily-version-action@v2
name: Create tag if necessary
id: daily-version
- if: steps.daily-version.outputs.created
name: Create release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: >
await github.request(`POST /repos/${{ github.repository
}}/releases`, {
tag_name: "${{ steps.daily-version.outputs.version }}",
generate_release_notes: true
});
Submit:
needs: Version
if: github.event_name == 'push' || needs.Version.outputs.created
if: github.event_name == 'workflow_dispatch' || needs.Version.outputs.created
strategy:
fail-fast: false
matrix:
command:
- firefox
- chrome
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npm test
- name: Update extension’s meta
run: |
export VER=$(echo "$GITHUB_REF" | sed -e 's/refs\/tags\///')
echo https://github.com/$GITHUB_REPOSITORY/tree/$VER > distribution/SOURCE_URL
npm run version
- uses: actions/upload-artifact@v1
with:
name: built-extension
path: distribution

Chrome:
needs: Build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v1
with:
name: built-extension
path: distribution
- run: cd distribution && npx chrome-webstore-upload-cli upload --auto-publish
env:
EXTENSION_ID: ${{ secrets.EXTENSION_ID }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}

Firefox:
needs: Build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v1
with:
name: built-extension
path: distribution
- run: cd distribution && npx web-ext-submit
env:
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- name: install
run: npm ci || npm install
- run: npm run build --if-present
- name: Update extension’s meta
run: >-
npx dot-json@1 $DIRECTORY/manifest.json version ${{
needs.Version.outputs.version }}
- name: Submit
run: |
case ${{ matrix.command }} in
chrome)
cd $DIRECTORY && npx chrome-webstore-upload-cli@2 upload --auto-publish
;;
firefox)
cd $DIRECTORY && npx web-ext-submit@7
;;
esac
env:
EXTENSION_ID: ${{ secrets.EXTENSION_ID }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}
11 changes: 8 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ on:
- push

jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npx lockfile-lint --path package-lock.json --validate-https
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npm test
- uses: actions/checkout@v2
- run: npm install
- run: npm test
1 change: 0 additions & 1 deletion size-plugin.json

This file was deleted.

2 changes: 0 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const fs = require('fs');
const path = require('path');

const SizePlugin = require('size-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const DefinePlugin = require('webpack').DefinePlugin;
Expand All @@ -17,7 +16,6 @@ module.exports = {
filename: '[name].js'
},
plugins: [
new SizePlugin(),
new DefinePlugin({
__INJECTIBLE_CODE__: JSON.stringify(fs.readFileSync('./source/injectible-code.js', 'utf-8'))
}),
Expand Down

0 comments on commit cc1972d

Please sign in to comment.