diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 185ec6b..1ffe6fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,7 @@ name: CI on: + workflow_call: push: branches: - main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b070d18 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,86 @@ +name: Release Chrome Extension + +on: + release: + types: + - published + +permissions: + contents: read + +concurrency: + group: release-${{ github.workflow }}-${{ github.event.release.tag_name }} + cancel-in-progress: true + +jobs: + quality: + uses: ./.github/workflows/ci.yml + permissions: + contents: read + + build-chrome: + name: Build Chrome + runs-on: ubuntu-24.04 + timeout-minutes: 10 + needs: + - quality + permissions: + contents: read + env: + ASSET_NAME: header-injector-chrome-${{ github.event.release.tag_name }}.zip + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 1 + persist-credentials: false + + - name: Setup Vite+ + uses: voidzero-dev/setup-vp@8ecb39174989ce55af90f45cf55b02738599831d # v1.6.0 + with: + version: "0.1.14" + node-version: "24.14.1" + cache: true + run-install: true + + - name: Build Chrome extension + run: vp run @header-injector/extension#build:chrome + + - name: Package Chrome extension + working-directory: apps/extension/dist/chrome + env: + ASSET_PATH: ${{ runner.temp }}/${{ env.ASSET_NAME }} + run: zip -r "$ASSET_PATH" . + + - name: Upload packaged artifact + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + env: + ASSET_PATH: ${{ runner.temp }}/${{ env.ASSET_NAME }} + with: + name: chrome-release-asset + path: ${{ env.ASSET_PATH }} + if-no-files-found: error + + upload-release-asset: + name: Upload Release Asset + runs-on: ubuntu-24.04 + timeout-minutes: 10 + needs: + - build-chrome + permissions: + contents: write + env: + ASSET_NAME: header-injector-chrome-${{ github.event.release.tag_name }}.zip + steps: + - name: Download packaged artifact + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: chrome-release-asset + path: ${{ runner.temp }}/release-asset + + - name: Upload release asset + env: + ASSET_PATH: ${{ runner.temp }}/release-asset/${{ env.ASSET_NAME }} + GH_TOKEN: ${{ github.token }} + TAG_NAME: ${{ github.event.release.tag_name }} + run: gh release upload "$TAG_NAME" "$ASSET_PATH" --repo "$GITHUB_REPOSITORY" --clobber