mirror of
https://github.com/momenbasel/keyFinder.git
synced 2026-06-08 00:53:55 +02:00
ci: add release + validation workflows
- release.yml: on v* tag, build Chrome + Firefox zips, compute SHA256, upload artifacts, attach to GitHub Release with auto generated notes - ci.yml: on PR/master push, validate manifest JSON, enforce version parity, build, web-ext lint Firefox bundle
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
validate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Validate manifest JSON
|
||||
run: |
|
||||
python3 -c "import json,sys; json.load(open('manifest.json'))"
|
||||
python3 -c "import json,sys; json.load(open('manifest.firefox.json'))"
|
||||
|
||||
- name: Manifest versions must match
|
||||
run: |
|
||||
C=$(python3 -c "import json; print(json.load(open('manifest.json'))['version'])")
|
||||
F=$(python3 -c "import json; print(json.load(open('manifest.firefox.json'))['version'])")
|
||||
[ "$C" = "$F" ] || { echo "Chrome=$C Firefox=$F"; exit 1; }
|
||||
|
||||
- name: Build runs cleanly
|
||||
run: bash scripts/build.sh
|
||||
|
||||
- name: Install web-ext
|
||||
run: npm install -g web-ext
|
||||
|
||||
- name: web-ext lint (Firefox)
|
||||
run: web-ext lint --source-dir dist/firefox --self-hosted
|
||||
@@ -0,0 +1,71 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Tag to build (e.g. v2.1.0). Leave blank to build current ref."
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.inputs.tag || github.ref }}
|
||||
|
||||
- name: Read version from manifest
|
||||
id: meta
|
||||
run: |
|
||||
VERSION=$(grep '"version"' manifest.json | head -1 | sed 's/.*: *"\([^"]*\)".*/\1/')
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Verify tag matches manifest version
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: |
|
||||
TAG="${GITHUB_REF#refs/tags/}"
|
||||
if [ "$TAG" != "${{ steps.meta.outputs.tag }}" ] && [ "$TAG" != "${{ steps.meta.outputs.tag }}-firefox" ]; then
|
||||
echo "Tag $TAG does not match manifest version ${{ steps.meta.outputs.tag }}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Build Chrome + Firefox zips
|
||||
run: bash scripts/build.sh
|
||||
|
||||
- name: Compute checksums
|
||||
working-directory: dist
|
||||
run: |
|
||||
shasum -a 256 keyfinder-v${{ steps.meta.outputs.version }}-chrome.zip > keyfinder-v${{ steps.meta.outputs.version }}-chrome.zip.sha256
|
||||
shasum -a 256 keyfinder-v${{ steps.meta.outputs.version }}-firefox.zip > keyfinder-v${{ steps.meta.outputs.version }}-firefox.zip.sha256
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: keyfinder-v${{ steps.meta.outputs.version }}
|
||||
path: |
|
||||
dist/keyfinder-v${{ steps.meta.outputs.version }}-chrome.zip
|
||||
dist/keyfinder-v${{ steps.meta.outputs.version }}-firefox.zip
|
||||
dist/keyfinder-v${{ steps.meta.outputs.version }}-chrome.zip.sha256
|
||||
dist/keyfinder-v${{ steps.meta.outputs.version }}-firefox.zip.sha256
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Attach to GitHub Release
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: |
|
||||
dist/keyfinder-v${{ steps.meta.outputs.version }}-chrome.zip
|
||||
dist/keyfinder-v${{ steps.meta.outputs.version }}-firefox.zip
|
||||
dist/keyfinder-v${{ steps.meta.outputs.version }}-chrome.zip.sha256
|
||||
dist/keyfinder-v${{ steps.meta.outputs.version }}-firefox.zip.sha256
|
||||
generate_release_notes: true
|
||||
fail_on_unmatched_files: true
|
||||
Reference in New Issue
Block a user