fix
Firefox extension release / Build, package and publish SKYNET SSO (release) Failing after 45s

Cette révision appartient à :
jimmyGALLAND authored and Jimmy GALLAND committed 2026-11-22 12:22:43 +01:00
1 Parent 5e5b4c5983
révision 670d251a6f
3 files changed
+36 -276

No files matched your search

+6
Voir le fichier
@@ -0,0 +1,6 @@
{
"license": "MIT",
"categories": [
"privacy-security"
]
}
+30 -23
Voir le fichier
@@ -1,4 +1,4 @@
name: Firefox extension release name: Firefox extension release
on: on:
release: release:
@@ -10,9 +10,10 @@ permissions:
jobs: jobs:
build-and-publish: build-and-publish:
name: Build, package and publish SKYNET SSO name: Build, package and publish SKYNET SSO
runs-on: ubuntu-latest runs-on: ubuntu-22.04
env: env:
EXTENSION_DIR: src/mod/auth/sso/zorxauth/extension EXTENSION_DIR: src/
RELEASE_TAG: ${{ gitea.event.release.tag_name }} RELEASE_TAG: ${{ gitea.event.release.tag_name }}
RELEASE_ID: ${{ gitea.event.release.id }} RELEASE_ID: ${{ gitea.event.release.id }}
REPOSITORY: ${{ gitea.repository }} REPOSITORY: ${{ gitea.repository }}
@@ -81,11 +82,6 @@ jobs:
echo "Release ${RELEASE_TAG} matches manifest version ${MANIFEST_VERSION}." echo "Release ${RELEASE_TAG} matches manifest version ${MANIFEST_VERSION}."
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install build tools - name: Install build tools
run: | run: |
npm install --no-save --no-audit --no-fund \ npm install --no-save --no-audit --no-fund \
@@ -109,7 +105,7 @@ jobs:
while IFS= read -r -d '' file; do while IFS= read -r -d '' file; do
tmp="${file}.min" tmp="${file}.min"
npx --no-install terser "${file}" \ npx --no-install terser "${file}" \
--compress --mangle --format "comments=false" \ --compress --mangle \
--output "${tmp}" --output "${tmp}"
mv "${tmp}" "${file}" mv "${tmp}" "${file}"
done < <(find dist -type f -name '*.js' -print0) done < <(find dist -type f -name '*.js' -print0)
@@ -123,18 +119,14 @@ jobs:
done < <(find dist -type f -name '*.css' -print0) done < <(find dist -type f -name '*.css' -print0)
while IFS= read -r -d '' file; do while IFS= read -r -d '' file; do
tmp="${file}.min" tmp="${file}.min"
npx --no-install html-minifier-terser \ npx --no-install html-minifier-terser \
--collapse-whitespace \ --collapse-whitespace \
--remove-comments \ --remove-comments \
--minify-css true \ --minify-css \
--minify-js false \ --keep-closing-slash \
--remove-optional-tags false \ "${file}" --output "${tmp}"
--remove-redundant-attributes false \ mv "${tmp}" "${file}"
--remove-attribute-quotes false \
--keep-closing-slash true \
"${file}" --output "${tmp}"
mv "${tmp}" "${file}"
done < <(find dist -type f -name '*.html' -print0) done < <(find dist -type f -name '*.html' -print0)
# Validate that the resulting manifest is still valid JSON and # Validate that the resulting manifest is still valid JSON and
@@ -188,16 +180,31 @@ jobs:
set -euo pipefail set -euo pipefail
mkdir -p artifacts/amo mkdir -p artifacts/amo
test -n "${AMO_JWT_ISSUER:-}" || {
echo "AMO_JWT_ISSUER absent"
exit 1
}
test -n "${AMO_JWT_SECRET:-}" || {
echo "AMO_JWT_SECRET absent"
exit 1
}
echo "Identifiants AMO présents."
echo "Longueur issuer : ${#AMO_JWT_ISSUER}"
echo "Longueur secret : ${#AMO_JWT_SECRET}"
npx --no-install web-ext sign \ npx --no-install web-ext sign \
--source-dir dist \ --source-dir dist \
--artifacts-dir artifacts/amo \ --artifacts-dir artifacts/amo \
--channel listed \ --channel unlisted \
--api-key "${AMO_JWT_ISSUER}" \ --api-key "${AMO_JWT_ISSUER}" \
--api-secret "${AMO_JWT_SECRET}" \ --api-secret "${AMO_JWT_SECRET}" \
--amo-metadata artifacts/amo-metadata.json \
--no-input --no-input
XPI="$(find artifacts/amo -maxdepth 1 -type f -name '*.xpi' -print -quit)" XPI="$(find artifacts/amo -maxdepth 1 -type f -name '*.xpi' -print -quit)"
if [[ -z "${XPI}" ]]; then if [[ -z "${XPI}" ]]; then
echo "::error::AMO did not return a signed XPI." echo "::error::AMO did not return a signed XPI."
exit 1 exit 1
fi fi
-253
Voir le fichier
@@ -1,253 +0,0 @@
name: Firefox extension release
on:
release:
types: [published]
permissions:
contents: write
jobs:
build-and-publish:
name: Build, package and publish SKYNET SSO
runs-on: ubuntu-latest
env:
EXTENSION_DIR: src
RELEASE_TAG: ${{ gitea.event.release.tag_name }}
RELEASE_ID: ${{ gitea.event.release.id }}
REPOSITORY: ${{ gitea.repository }}
GITEA_SERVER_URL: ${{ gitea.server_url }}
GITEA_SHA: ${{ gitea.sha }}
steps:
- name: Checkout release commit
uses: actions/checkout@v4
with:
ref: ${{ gitea.sha }}
fetch-depth: 0
token: ${{ secrets.GITEA_TOKEN }}
- name: Ensure the release tag exists
shell: bash
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
set -euo pipefail
if [[ -z "${RELEASE_TAG}" ]]; then
echo "::error::The release event does not contain a tag name."
exit 1
fi
git fetch --force origin \
"+refs/tags/${RELEASE_TAG}:refs/tags/${RELEASE_TAG}" \
2>/dev/null || true
if git show-ref --verify --quiet "refs/tags/${RELEASE_TAG}"; then
echo "Tag ${RELEASE_TAG} already exists."
else
if [[ -z "${GITEA_SHA}" ]]; then
echo "::error::Cannot create the tag: the release commit SHA is missing."
exit 1
fi
git tag -a "${RELEASE_TAG}" "${GITEA_SHA}" \
-m "Release ${RELEASE_TAG}"
# Use an HTTP authorization header so the token is not embedded
# in the remote URL or written to the Git configuration.
AUTH="$(printf 'x-access-token:%s' "${GITEA_TOKEN}" | base64 -w 0)"
git -c http.extraheader="AUTHORIZATION: basic ${AUTH}" \
push origin "refs/tags/${RELEASE_TAG}"
fi
git checkout --detach "refs/tags/${RELEASE_TAG}"
echo "Release tag points to $(git rev-parse HEAD)."
- name: Validate release version
shell: bash
run: |
set -euo pipefail
TAG_VERSION="${RELEASE_TAG#v}"
MANIFEST_VERSION="$(node -p \
"require('./${EXTENSION_DIR}/manifest.json').version")"
if [[ "${TAG_VERSION}" != "${MANIFEST_VERSION}" ]]; then
echo "::error::Release tag ${RELEASE_TAG} does not match manifest version ${MANIFEST_VERSION}."
echo "Expected tag: v${MANIFEST_VERSION} (or ${MANIFEST_VERSION})."
exit 1
fi
echo "Release ${RELEASE_TAG} matches manifest version ${MANIFEST_VERSION}."
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install build tools
run: |
npm install --no-save --no-audit --no-fund \
terser@5.44.1 \
clean-css-cli@5.6.3 \
html-minifier-terser@7.2.0 \
web-ext@8.9.0
- name: Prepare and safely minify extension
shell: bash
run: |
set -euo pipefail
rm -rf dist artifacts
mkdir -p dist artifacts
cp -a "${EXTENSION_DIR}/." dist/
rm -f dist/README.md
# Minify JavaScript, CSS and HTML in the build copy only.
# The tracked source files are never rewritten.
while IFS= read -r -d '' file; do
tmp="${file}.min"
npx --no-install terser "${file}" \
--compress --mangle --format "comments=false" \
--output "${tmp}"
mv "${tmp}" "${file}"
done < <(find dist -type f -name '*.js' -print0)
while IFS= read -r -d '' file; do
tmp="${file}.min"
npx --no-install cleancss \
--compatibility ie11 -O2 \
--output "${tmp}" "${file}"
mv "${tmp}" "${file}"
done < <(find dist -type f -name '*.css' -print0)
while IFS= read -r -d '' file; do
tmp="${file}.min"
npx --no-install html-minifier-terser \
--collapse-whitespace \
--remove-comments \
--minify-css true \
--minify-js false \
--remove-optional-tags false \
--remove-redundant-attributes false \
--remove-attribute-quotes false \
--keep-closing-slash true \
"${file}" --output "${tmp}"
mv "${tmp}" "${file}"
done < <(find dist -type f -name '*.html' -print0)
# Validate that the resulting manifest is still valid JSON and
# that all referenced entry-point files are present.
node <<'NODE'
const fs = require("node:fs");
const path = require("node:path");
const root = path.resolve("dist");
const manifest = JSON.parse(fs.readFileSync(path.join(root, "manifest.json"), "utf8"));
const required = [
...(manifest.background?.scripts || []),
...(manifest.content_scripts || []).flatMap(s => [
...(s.js || []),
...(s.css || [])
]),
...(manifest.options_ui?.page ? [manifest.options_ui.page] : []),
...(manifest.action?.default_popup ? [manifest.action.default_popup] : []),
...Object.values(manifest.icons || {}),
...(manifest.web_accessible_resources || []).flatMap(r => r.resources || [])
];
for (const entry of required) {
const target = path.resolve(root, entry);
if (!target.startsWith(root + path.sep) || !fs.existsSync(target)) {
throw new Error(`Manifest resource missing or invalid: ${entry}`);
}
}
console.log(`Manifest OK; ${required.length} referenced resources verified.`);
NODE
npx --no-install web-ext lint --source-dir dist
ZIP_NAME="SKYNET-SSO-${RELEASE_TAG}.zip"
(
cd dist
zip -qr "../artifacts/${ZIP_NAME}" .
)
echo "ZIP_NAME=${ZIP_NAME}" >> "${GITEA_ENV:-$GITHUB_ENV}"
echo "ZIP_PATH=artifacts/${ZIP_NAME}" >> "${GITEA_ENV:-$GITHUB_ENV}"
- name: Sign and submit to Firefox Add-ons (AMO)
id: amo
if: ${{ secrets.AMO_JWT_ISSUER != '' && secrets.AMO_JWT_SECRET != '' }}
env:
AMO_JWT_ISSUER: ${{ secrets.AMO_JWT_ISSUER }}
AMO_JWT_SECRET: ${{ secrets.AMO_JWT_SECRET }}
run: |
set -euo pipefail
mkdir -p artifacts/amo
npx --no-install web-ext sign \
--source-dir dist \
--artifacts-dir artifacts/amo \
--channel listed \
--api-key "${AMO_JWT_ISSUER}" \
--api-secret "${AMO_JWT_SECRET}" \
--no-input
XPI="$(find artifacts/amo -maxdepth 1 -type f -name '*.xpi' -print -quit)"
if [[ -z "${XPI}" ]]; then
echo "::error::AMO did not return a signed XPI."
exit 1
fi
cp "${XPI}" "artifacts/SKYNET-SSO-${RELEASE_TAG}.xpi"
echo "AMO submission/signing completed."
- name: Upload release files to Gitea
shell: bash
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
AMO_JWT_ISSUER: ${{ secrets.AMO_JWT_ISSUER }}
AMO_JWT_SECRET: ${{ secrets.AMO_JWT_SECRET }}
run: |
set -euo pipefail
if [[ -z "${GITEA_TOKEN}" ]]; then
echo "::error::Add the GITEA_TOKEN repository secret (write access required)."
exit 1
fi
API_BASE="${GITEA_SERVER_URL%/}/api/v1"
OWNER="${REPOSITORY%%/*}"
REPO="${REPOSITORY#*/}"
AUTH_HEADER="Authorization: token ${GITEA_TOKEN}"
upload_asset() {
local file="$1"
local name
name="$(basename "${file}")"
echo "Uploading ${name} to release ${RELEASE_TAG}..."
curl --fail --silent --show-error \
--request POST \
--header "${AUTH_HEADER}" \
--form "attachment=@${file}" \
"${API_BASE}/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}/assets?name=${name}"
}
upload_asset "artifacts/${ZIP_NAME}"
if [[ -f "artifacts/SKYNET-SSO-${RELEASE_TAG}.xpi" ]]; then
upload_asset "artifacts/SKYNET-SSO-${RELEASE_TAG}.xpi"
else
echo "AMO credentials are not configured; ZIP is attached, AMO publication skipped."
fi
- name: Preserve build files in workflow artifacts
uses: actions/upload-artifact@v3
with:
name: SKYNET-SSO-${{ gitea.event.release.tag_name }}
path: artifacts/*
if-no-files-found: error