Skip to content

Add go.sum entries for silo-plugin-sdk #3

Add go.sum entries for silo-plugin-sdk

Add go.sum entries for silo-plugin-sdk #3

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Determine version
id: version
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
tag="${GITHUB_REF_NAME}"
version="${tag#v}"
else
# Auto-increment patch from latest tag.
latest=$(git tag -l 'v*' --sort=-v:refname | head -n1)
if [ -z "$latest" ]; then
version="1.0.0"
else
base="${latest#v}"
IFS='.' read -r major minor patch <<< "$base"
patch=$((patch + 1))
version="${major}.${minor}.${patch}"
fi
tag="v${version}"
# Update manifest.json so the catalog tool sees the correct version.
jq --arg v "$version" '.version = $v' manifest.json > manifest.tmp && mv manifest.tmp manifest.json
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add manifest.json
git commit -m "chore: bump version to ${version} [skip ci]"
git tag "$tag"
git push origin HEAD:main --tags
fi
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
build:
needs: version
strategy:
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
- os: ubuntu-latest
goos: linux
goarch: arm64
- os: macos-latest
goos: darwin
goarch: arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.version.outputs.tag }}
- uses: actions/setup-go@v6
with:
go-version: '1.26'
- name: Configure module resolution
run: |
go env -w GOPROXY=direct
go env -w GOPRIVATE=github.com/Silo-Server/*
go env -w GONOSUMDB=github.com/Silo-Server/*
- name: Reject committed local SDK replaces
run: |
if grep -Eq '^replace github.com/Silo-Server/silo-plugin-sdk => /' go.mod; then
echo "go.mod contains a machine-local silo-plugin-sdk replace."
exit 1
fi
- name: Build plugin binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: '0'
GOWORK: off
run: |
mkdir -p dist
binary="plugin-${GOOS}-${GOARCH}"
version="${{ needs.version.outputs.version }}"
go build -trimpath -ldflags="-s -w -X main.version=${version}" -o "dist/${binary}" .
checksum=$(shasum -a 256 "dist/${binary}" | awk '{print $1}')
printf '%s %s\n' "$checksum" "$binary" > dist/checksums.txt
sed "s/__CHECKSUM__/${checksum}/" manifest.json > "dist/manifest-${GOOS}-${GOARCH}.json"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: plugin-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
dist/plugin-${{ matrix.goos }}-${{ matrix.goarch }}
dist/checksums.txt
dist/manifest-${{ matrix.goos }}-${{ matrix.goarch }}.json
release:
needs: [version, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release
: > release/checksums.txt
for dir in artifacts/plugin-*; do
platform=$(basename "$dir" | sed 's/plugin-//')
cp "${dir}/plugin-${platform}" "release/plugin-${platform}"
cat "${dir}/checksums.txt" >> release/checksums.txt
done
sort -u -o release/checksums.txt release/checksums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.version.outputs.tag }}
files: |
release/plugin-linux-amd64
release/plugin-linux-arm64
release/plugin-darwin-arm64
release/checksums.txt
generate_release_notes: true
- name: Notify silo-plugins catalog
env:
DISPATCH_TOKEN: ${{ secrets.SILO_PLUGINS_DISPATCH_TOKEN }}
run: |
if [ -z "$DISPATCH_TOKEN" ]; then
echo "SILO_PLUGINS_DISPATCH_TOKEN is not set; skipping catalog dispatch."
exit 0
fi
curl --fail --silent --show-error \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${DISPATCH_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/Silo-Server/silo-plugins/dispatches \
-d "$(printf '{"event_type":"plugin_release_published","client_payload":{"repo":"Silo-Server/silo-plugin-tmdb","tag":"%s"}}' "${{ needs.version.outputs.tag }}")"