name: Build Firefox Extension on: push: branches: - main tags: - 'v*' pull_request: branches: - main jobs: build: runs-on: docker permissions: contents: read packages: write container: image: node:20-alpine steps: - name: Install dependencies run: apk add --no-cache zip jq git curl - name: Checkout repository uses: actions/checkout@v3 - name: Get version from manifest id: version run: | VERSION=$(jq -r '.version' manifest.json) echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Building version: $VERSION" - name: Create extension package run: | # Create build directory mkdir -p build # Package the extension as XPI (which is just a ZIP file) zip -r build/container-bookmarks-${{ steps.version.outputs.version }}.xpi \ manifest.json \ background.js \ icons/ \ popup/ \ README.md \ -x "*.git*" \ -x "*.md" \ -x "build/*" \ -x "node_modules/*" \ -x ".gitea/*" # Also create a ZIP for convenience cp build/container-bookmarks-${{ steps.version.outputs.version }}.xpi \ build/container-bookmarks-${{ steps.version.outputs.version }}.zip - name: Upload to Gitea Packages run: | curl --fail \ -H "Authorization: token ${{ secrets.ACCESS_TOKEN }}" \ --upload-file "build/container-bookmarks-${{ steps.version.outputs.version }}.xpi" \ "${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/generic/container-bookmarks/${{ steps.version.outputs.version }}/container-bookmarks-${{ steps.version.outputs.version }}.xpi" release: runs-on: docker container: image: node:20-alpine needs: build if: startsWith(github.ref, 'refs/tags/v') steps: - name: Install dependencies run: apk add --no-cache jq git curl - name: Checkout repository uses: actions/checkout@v3 - name: Get version from manifest id: version run: | VERSION=$(jq -r '.version' manifest.json) echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Download from Gitea Packages run: | mkdir -p build curl --fail -o "build/container-bookmarks-${{ steps.version.outputs.version }}.xpi" \ "${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/generic/container-bookmarks/${{ steps.version.outputs.version }}/container-bookmarks-${{ steps.version.outputs.version }}.xpi" - name: Create Release uses: softprops/action-gh-release@v1 with: files: build/*.xpi generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}