Merge pull request #8 from imigueldiaz/restructure-addon #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build, Sign, and Release Firefox Extension | |
name: Build, Sign, and Release Firefox Extension | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
jobs: | |
check-manifest: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Check if manifest.json has changed | |
id: check-manifest | |
run: | | |
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD) | |
if ! echo "$CHANGED_FILES" | grep -q "manifest.json"; then | |
echo "manifest.json has not changed" | |
echo "manifest_changed=false" >> $GITHUB_OUTPUT | |
else | |
echo "manifest.json has changed" | |
echo "manifest_changed=true" >> $GITHUB_OUTPUT | |
fi | |
outputs: | |
manifest_changed: ${{ steps.check-manifest.outputs.manifest_changed }} | |
build-and-release: | |
needs: check-manifest | |
if: ${{ needs.check-manifest.outputs.manifest_changed == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
- name: Install web-ext | |
run: npm install --global web-ext | |
- name: Build and sign the extension | |
run: web-ext sign --artifacts-dir ./artifacts --api-key ${{ secrets.AMO_JWT_ISSUER }} --api-secret ${{ secrets.AMO_JWT_SECRET }} | |
env: | |
WEB_EXT_API_KEY: ${{ secrets.JWT_ISSUER }} | |
WEB_EXT_API_SECRET: ${{ secrets.JWT_SECRET }} | |
- name: Find signed XPI file name | |
id: find-xpi | |
run: | | |
XPI_FILE=$(ls ./artifacts/*.xpi) | |
echo "xpi_name=$(basename "$XPI_FILE" .xpi)" >> $GITHUB_OUTPUT | |
- name: Extract version for tag and release name | |
id: extract-version | |
run: | | |
XPI_NAME="${{ steps.find-xpi.outputs.xpi_name }}" | |
VERSION_PART=$(echo "$XPI_NAME" | cut -d '-' -f 2) | |
echo "version=$VERSION_PART" >> $GITHUB_OUTPUT | |
- name: Copy signed XPI to real name | |
id: copy-xpi | |
run: | | |
cp ./artifacts/${{ steps.find-xpi.outputs.xpi_name }}.xpi ./artifacts/quick_abstract.xpi | |
- name: Configure Git | |
run: | | |
git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" | |
git config --global user.name "${{ secrets.GIT_USER_NAME }}" | |
- name: Upload signed XPI as quick_abstract.xpi | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: ./artifacts/quick_abstract.xpi | |
name: quick_abstract-${{ steps.extract-version.outputs.version }} | |
tag_name: v${{ steps.extract-version.outputs.version }} | |
draft: false | |
prerelease: false | |
make_latest: true | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |