From aaa31e37c79f61537b8fc9ddc35b0d714683cde7 Mon Sep 17 00:00:00 2001 From: scanash00 Date: Thu, 9 Jul 2026 05:44:18 -0800 Subject: [PATCH] forgejo workflows --- .forgejo/workflows/docker-publish.yml | 122 +++++++++++++++++++++++ .forgejo/workflows/release-extension.yml | 113 +++++++++++++++++++++ .forgejo/workflows/sponsors.yml | 28 ++++++ 3 files changed, 263 insertions(+) create mode 100644 .forgejo/workflows/docker-publish.yml create mode 100644 .forgejo/workflows/release-extension.yml create mode 100644 .forgejo/workflows/sponsors.yml diff --git a/.forgejo/workflows/docker-publish.yml b/.forgejo/workflows/docker-publish.yml new file mode 100644 index 0000000..56ccd71 --- /dev/null +++ b/.forgejo/workflows/docker-publish.yml @@ -0,0 +1,122 @@ +name: Build and Publish Docker Image + +on: + push: + branches: ["main"] + workflow_dispatch: + +env: + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + include: + - platform: linux/amd64 + runner: amd64 + arch: amd64 + - platform: linux/arm64 + runner: arm64 + arch: arm64 + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set registry host + run: | + URL="${{ github.server_url }}" + REGISTRY="${URL#https://}" + REGISTRY="${REGISTRY#http://}" + echo "REGISTRY=$REGISTRY" >> $GITHUB_ENV + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push by digest + id: build + uses: docker/build-push-action@v6 + with: + context: . + platforms: ${{ matrix.platform }} + outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true + + - name: Export digest + run: | + mkdir -p /tmp/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ matrix.arch }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + + manifest: + runs-on: docker + needs: build + permissions: + contents: read + packages: write + + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: digests-* + merge-multiple: true + + - name: Set registry host + run: | + URL="${{ github.server_url }}" + REGISTRY="${URL#https://}" + REGISTRY="${REGISTRY#http://}" + echo "REGISTRY=$REGISTRY" >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=sha + + - name: Create manifest list and push + working-directory: /tmp/digests + run: | + IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" + TAGS=$(printf '%s\n' "${{ steps.meta.outputs.tags }}" | sed 's/^/-t /' | tr '\n' ' ') + docker buildx imagetools create $TAGS $(printf "${IMAGE}@sha256:%s " *) + + - name: Inspect image + run: | + IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" + docker buildx imagetools inspect "${IMAGE}:latest" diff --git a/.forgejo/workflows/release-extension.yml b/.forgejo/workflows/release-extension.yml new file mode 100644 index 0000000..ee76237 --- /dev/null +++ b/.forgejo/workflows/release-extension.yml @@ -0,0 +1,113 @@ +name: Release Extension + +on: + push: + tags: + - "v*" + +jobs: + release: + runs-on: docker + permissions: + contents: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install dependencies + run: | + cd extension + bun install + + - name: Update Version + run: | + VERSION=${GITHUB_REF_NAME#v} + echo "Updating to version $VERSION" + cd extension + tmp=$(mktemp) + jq --arg v "$VERSION" '.version = $v' package.json > "$tmp" && mv "$tmp" package.json + + - name: Build Chrome Extension + run: | + cd extension + bun run zip + cp .output/margin-extension-*.zip ../margin-extension-chrome.zip + + - name: Build Firefox Extension + run: | + cd extension + bun run zip:firefox + cp .output/margin-extension-*-firefox.zip ../margin-extension-firefox.xpi + cp .output/margin-extension-*-sources.zip ../margin-extension-sources.zip + + - name: Publish to Chrome Web Store + continue-on-error: true + uses: mobilefirstllc/cws-publish@latest + with: + action: publish + client_id: ${{ secrets.CHROME_CLIENT_ID }} + client_secret: ${{ secrets.CHROME_CLIENT_SECRET }} + refresh_token: ${{ secrets.CHROME_REFRESH_TOKEN }} + extension_id: ${{ secrets.CHROME_EXTENSION_ID }} + zip_file: margin-extension-chrome.zip + + - name: Publish to Edge Add-ons + continue-on-error: true + run: | + echo "Uploading package to Edge Add-ons..." + curl \ + -H "Authorization: ApiKey ${{ secrets.EDGE_API_KEY }}" \ + -H "X-ClientID: ${{ secrets.EDGE_CLIENT_ID }}" \ + -H "Content-Type: application/zip" \ + -X POST \ + -T margin-extension-chrome.zip \ + -f -sS \ + https://api.addons.microsoftedge.microsoft.com/v1/products/${{ secrets.EDGE_PRODUCT_ID }}/submissions/draft/package + + echo "Publishing submission..." + curl \ + -H "Authorization: ApiKey ${{ secrets.EDGE_API_KEY }}" \ + -H "X-ClientID: ${{ secrets.EDGE_CLIENT_ID }}" \ + -X POST \ + -d '{ "notes": "New release" }' \ + -f -sS \ + https://api.addons.microsoftedge.microsoft.com/v1/products/${{ secrets.EDGE_PRODUCT_ID }}/submissions + + - name: Publish to Firefox AMO + continue-on-error: true + env: + AMO_JWT_ISSUER: ${{ secrets.AMO_JWT_ISSUER }} + AMO_JWT_SECRET: ${{ secrets.AMO_JWT_SECRET }} + run: | + cd extension + COMMIT_MSG=$(git log -1 --pretty=%s) + echo "{\"release_notes\": {\"en-US\": \"$COMMIT_MSG\"}, \"notes\": \"Thank you!\"}" > amo-metadata.json + ./node_modules/.bin/web-ext sign --channel=listed --api-key=$AMO_JWT_ISSUER --api-secret=$AMO_JWT_SECRET --source-dir=.output/firefox-mv3 --artifacts-dir=../web-ext-artifacts --approval-timeout=300000 --amo-metadata=amo-metadata.json || echo "Web-ext sign timed out (expected), continuing..." + rm amo-metadata.json + + - name: Prepare signed Firefox XPI + run: | + if ls web-ext-artifacts/*.xpi 1> /dev/null 2>&1; then + SIGNED_XPI=$(ls web-ext-artifacts/*.xpi | head -1) + echo "Found signed XPI: $SIGNED_XPI" + cp "$SIGNED_XPI" margin-extension-firefox.xpi + else + echo "No signed XPI found, using unsigned build" + fi + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + files: | + margin-extension-chrome.zip + margin-extension-firefox.xpi + margin-extension-sources.zip + generate_release_notes: true + draft: false + prerelease: false diff --git a/.forgejo/workflows/sponsors.yml b/.forgejo/workflows/sponsors.yml new file mode 100644 index 0000000..31a5c39 --- /dev/null +++ b/.forgejo/workflows/sponsors.yml @@ -0,0 +1,28 @@ +name: Generate Sponsors README +on: + workflow_dispatch: + schedule: + - cron: "30 15 * * 0-6" +permissions: + contents: write +jobs: + deploy: + runs-on: docker + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v2 + + - name: Generate Sponsors 💖 + uses: JamesIves/github-sponsors-readme-action@v1.6.0 + with: + token: ${{ secrets.GH_SPONSORS_TOKEN }} + file: README.md + organization: true + minimum: 2500 + maximum: 2500 + + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: main + folder: "." -- knotmirror 0.0.1