Add GitHub Actions workflows for build, release, and PR download link
This commit is contained in:
40
.github/workflows/build.yml
vendored
Normal file
40
.github/workflows/build.yml
vendored
Normal file
@@ -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
|
||||
41
.github/workflows/release.yml
vendored
Normal file
41
.github/workflows/release.yml
vendored
Normal file
@@ -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
|
||||
36
.github/workflows/update-link-on-pr.yml
vendored
Normal file
36
.github/workflows/update-link-on-pr.yml
vendored
Normal file
@@ -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)
|
||||
2
Makefile
2
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
|
||||
|
||||
Reference in New Issue
Block a user