Ensure the token has write permissions for contents #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'CI/CD Pipeline' | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
build: | |
name: "Build" | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v3 | |
- name: "web-ext build" | |
id: web-ext-build | |
uses: kewisch/action-web-ext@v1 | |
with: | |
cmd: build | |
source: src | |
filename: "{name}-{version}.xpi" | |
env: | |
WEB_EXT_FILENAME: "{name}-{version}.xpi" | |
- name: Print filename | |
run: echo "The generated file is ${{ env.WEB_EXT_FILENAME }}" | |
release: | |
runs-on: ubuntu-latest | |
needs: build # Ensure the build job completes first | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v3 | |
- name: "web-ext build" | |
id: web-ext-build | |
uses: kewisch/action-web-ext@v1 | |
with: | |
cmd: build | |
source: src | |
filename: "{name}-{version}.xpi" | |
- name: "Web Ext Sign" | |
id: web-ext-sign | |
uses: kewisch/action-web-ext@v1 | |
with: | |
cmd: sign | |
source: ${{ steps.web-ext-build.outputs.target }} | |
channel: listed | |
apiKey: ${{ secrets.AMO_SIGN_KEY }} | |
apiSecret: ${{ secrets.AMO_SIGN_SECRET }} | |
timeout: 900000 | |
- name: "Create GitHub Release" | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: "Release ${{ github.ref }}" | |
draft: false | |
prerelease: false | |
- name: "Upload Release Asset" | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ steps.web-ext-build.outputs.target }} | |
asset_name: "{name}-{version}.xpi" | |
asset_content_type: application/x-xpinstall |