From 38391cd178ded01b18853df91d09a9dc150650a0 Mon Sep 17 00:00:00 2001 From: deluan Date: Tue, 3 Feb 2026 10:25:48 -0500 Subject: [PATCH] Add GitHub Actions workflows for build, release, and PR download link --- .github/workflows/build.yml | 40 ++++++++++++++++++++++++ .github/workflows/release.yml | 41 +++++++++++++++++++++++++ .github/workflows/update-link-on-pr.yml | 36 ++++++++++++++++++++++ Makefile | 2 +- 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/update-link-on-pr.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c445bd0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,40 @@ +name: Build + +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v5 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Install TinyGo + run: | + wget https://github.com/tinygo-org/tinygo/releases/download/v0.40.1/tinygo_0.40.1_amd64.deb + sudo dpkg -i tinygo_0.40.1_amd64.deb + sudo apt install -y binaryen + + - name: Run tests + run: make test + + - name: Build and package plugin + run: make package + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: discord-rich-presence + path: discord-rich-presence.ndp diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..254cb09 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +name: Release + +on: + push: + tags: + - "v*" + +permissions: + contents: write + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v5 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Install TinyGo + run: | + wget https://github.com/tinygo-org/tinygo/releases/download/v0.40.1/tinygo_0.40.1_amd64.deb + sudo dpkg -i tinygo_0.40.1_amd64.deb + sudo apt install -y binaryen + + - name: Run tests + run: make test + + - name: Build and package plugin + run: make package + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + draft: true + files: discord-rich-presence.ndp + generate_release_notes: true diff --git a/.github/workflows/update-link-on-pr.yml b/.github/workflows/update-link-on-pr.yml new file mode 100644 index 0000000..2282ada --- /dev/null +++ b/.github/workflows/update-link-on-pr.yml @@ -0,0 +1,36 @@ +name: Add download link to PR + +on: + workflow_run: + workflows: ["Build"] + types: [completed] + +jobs: + pr_comment: + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Get PR number + id: pr + uses: actions/github-script@v7 + with: + script: | + const pulls = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open' + }); + const pr = pulls.data.find(p => p.head.sha === '${{ github.event.workflow_run.head_sha }}'); + if (pr) { + core.setOutput('number', pr.number); + } + + - name: Add download link comment + if: steps.pr.outputs.number + uses: marocchino/sticky-pull-request-comment@v2 + with: + number: ${{ steps.pr.outputs.number }} + message: | + Download the plugin for this PR: [discord-rich-presence.zip](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/discord-rich-presence.zip) diff --git a/Makefile b/Makefile index 587c85e..bc3e511 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ test: go test -race ./... build: - tinygo build -target wasip1 -buildmode=c-shared -o $(WASM_FILE) -scheduler=none . + tinygo build -opt=2 -scheduler=none -no-debug -o $(WASM_FILE) -target wasi -buildmode=c-shared . package: build zip $(PLUGIN_NAME).ndp $(WASM_FILE) manifest.json