Skip to content

fix: sign extension using web-ext nodejs #13

fix: sign extension using web-ext nodejs

fix: sign extension using web-ext nodejs #13

Workflow file for this run

name: '🚀 ESEO Tools Release'
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
ESEO-Tools-release:
runs-on: ubuntu-latest
environment: env
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update manifest
run: |
cat manifest.json
# Get the version from the tag and remove the v
VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\/v//')
# Update the manifest and popup with the new version
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" manifest.json
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" manifest-chrome.json
sed -i "s/<p id=\"version\"><\/p>/<p id=\"version\">v$VERSION<\/p>/" popup/index.html
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Sign the extension
id: sign_extension
run: |
npm install --global web-ext
web-ext sign --api-key="${{ secrets.FIREFOX_JWT_ISSUER }}" --api-secret="${{ secrets.FIREFOX_JWT_SECRET }}" --channel=unlisted
echo "xpi_file=$(ls -t web-ext-artifacts/*.xpi | head -1)" >> $GITHUB_ENV
- name: Mettre à jour le fichier update.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git clone --branch gh-pages https://github.com/matthieuEv/Eseo-tools.git gh-pages
cd gh-pages
git config --global user.email "example@example.com"
git config --global user.name "Github Actions"
ls -la
sudo apt-get update
sudo apt-get install -y jq
ls -la
git config --global user.email "example@example.com"
git config --global user.name "Github Actions"
ls -la
# Variables
NEW_VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\/v//')
OUTPUT_FILE=$(echo ${{ env.xpi_file }} | sed 's/web-ext-artifacts\///')
UPDATE_LINK="https://matthieuev.github.io/Eseo-tools/$OUTPUT_FILE"
JSON_FILE="updates.json"
ADDON_ID="{3e2f33e0-e00d-48fb-9f13-8b603f960faf}"
# Lire le fichier JSON existant et ajouter la nouvelle version
jq --arg new_version "$NEW_VERSION" --arg update_link "$UPDATE_LINK" --arg addon_id "$ADDON_ID" \
'.addons[$addon_id].updates += [{"version": $new_version, "update_link": $update_link}]' "$JSON_FILE" > tmp.$$.json && mv tmp.$$.json "$JSON_FILE"
echo ">>>"
cat $JSON_FILE
git add $JSON_FILE
git commit -m "Ajout de la version $NEW_VERSION au fichier $JSON_FILE"
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/matthieuEv/Eseo-tools.git gh-pages
- name: Create Zip for Chrome
run: |
rm manifest.json
mv manifest-chrome.json manifest.json
zip -r eseo-tools-for-chrome.zip . -x ".github/*" -x ".git/*"
- name: Create Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: |
## How to install
For Firefox, Simply download the `.xpi` file under this release, and it will automatically install it on your browser.
For Chrome, you must follow these steps:
- Download the `eseo-tools-for-chrome.zip` under this release
- Unzip it where you want to
- Go to chromium/chrome *Extension* settings.
- Click to check *Developer mode*
- Click *Load unpacked extension* and select the folder you unziped
files: |
${{ env.xpi_file }}
eseo-tools-for-chrome.zip
- name: Create Github Pages
run: |
mkdir release
# 2 copy, one for the latest that overwrite the previous one, and one for the versioned file
cp ${{ env.xpi_file }} release/eseo-tools.xpi
cp ${{ env.xpi_file }} release
# cp gh-pages/updates.json release
echo '<!DOCTYPE html><html><head><title>Eseo Tools</title></head><div id="example-option-1" class="install-ok"><a href="https://matthieuev.github.io/Eseo-tools/eseo-tools.xpi">Install my add-on</a></div></html>' > release/index.html
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@4.1.5
with:
branch: gh-pages
folder: release