Skip to content

fix: restore split tool markers across CPA callbacks #19

fix: restore split tool markers across CPA callbacks

fix: restore split tool markers across CPA callbacks #19

Workflow file for this run

name: Build
on:
pull_request:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
env:
PLUGIN_ID: cpa-sensitive
jobs:
test:
name: Test
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Test
run: go test ./...
- name: Vet
run: go vet ./...
build:
name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
needs: test
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
runner: ubuntu-24.04
ext: so
- goos: linux
goarch: arm64
runner: ubuntu-24.04-arm
ext: so
- goos: darwin
goarch: amd64
runner: macos-15-intel
ext: dylib
- goos: darwin
goarch: arm64
runner: macos-15
ext: dylib
- goos: windows
goarch: amd64
runner: windows-2025
ext: dll
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Resolve release metadata
run: |
set -euo pipefail
if [[ "${GITHUB_REF_TYPE}" == "tag" && "${GITHUB_REF_NAME}" == v* ]]; then
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="0.0.0-dev"
fi
echo "VERSION=${VERSION}" >> "${GITHUB_ENV}"
echo "LIB_NAME=${PLUGIN_ID}.${{ matrix.ext }}" >> "${GITHUB_ENV}"
echo "ARCHIVE_NAME=${PLUGIN_ID}_${VERSION}_${{ matrix.goos }}_${{ matrix.goarch }}.zip" >> "${GITHUB_ENV}"
- name: Build shared library
run: |
set -euo pipefail
mkdir -p dist
CGO_ENABLED=1 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
go build -trimpath -buildmode=c-shared \
-ldflags "-s -w -X main.cpaSensitivePluginVersion=${VERSION}" \
-o "dist/${LIB_NAME}" .
rm -f "dist/${PLUGIN_ID}.h"
- name: Package plugin
run: |
set -euo pipefail
go run ./.github/scripts/package-release.go \
-library "dist/${LIB_NAME}" \
-archive "${ARCHIVE_NAME}" \
-checksum "${ARCHIVE_NAME}.sha256"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE_NAME }}
path: |
${{ env.ARCHIVE_NAME }}
${{ env.ARCHIVE_NAME }}.sha256
if-no-files-found: error
build-windows-arm64:
name: Build windows/arm64
needs: test
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Resolve release metadata
id: release_metadata
run: |
set -euo pipefail
if [[ "${GITHUB_REF_TYPE}" == "tag" && "${GITHUB_REF_NAME}" == v* ]]; then
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="0.0.0-dev"
fi
echo "VERSION=${VERSION}" >> "${GITHUB_ENV}"
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
echo "ARCHIVE_NAME=${PLUGIN_ID}_${VERSION}_windows_arm64.zip" >> "${GITHUB_ENV}"
- name: Build Windows ARM64 shared library
timeout-minutes: 45
uses: go-cross/cgo-actions@v1
env:
GOFLAGS: -trimpath -buildmode=c-shared
with:
dir: .
packages: .
targets: windows-arm64
out-dir: dist/windows-arm64
output: ${{ env.PLUGIN_ID }}.dll
flags: -ldflags=-s -w
x-flags: main.cpaSensitivePluginVersion=${{ steps.release_metadata.outputs.version }}
- name: Package plugin
run: |
set -euo pipefail
rm -f go-cross-bin.h "dist/windows-arm64/${PLUGIN_ID}.h"
go run ./.github/scripts/package-release.go \
-library "dist/windows-arm64/${PLUGIN_ID}.dll" \
-archive "${ARCHIVE_NAME}" \
-checksum "${ARCHIVE_NAME}.sha256"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE_NAME }}
path: |
${{ env.ARCHIVE_NAME }}
${{ env.ARCHIVE_NAME }}.sha256
if-no-files-found: error
build-freebsd:
name: Build freebsd/${{ matrix.goarch }}
needs: test
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- goarch: amd64
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Resolve release metadata
id: release_metadata
run: |
set -euo pipefail
if [[ "${GITHUB_REF_TYPE}" == "tag" && "${GITHUB_REF_NAME}" == v* ]]; then
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="0.0.0-dev"
fi
echo "VERSION=${VERSION}" >> "${GITHUB_ENV}"
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
echo "ARCHIVE_NAME=${PLUGIN_ID}_${VERSION}_freebsd_${{ matrix.goarch }}.zip" >> "${GITHUB_ENV}"
- name: Install FreeBSD cross-build dependencies
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y clang lld wget
- name: Build FreeBSD shared library
timeout-minutes: 45
uses: go-cross/cgo-actions@v1
env:
GOFLAGS: -trimpath -buildmode=c-shared
with:
dir: .
packages: .
targets: freebsd-${{ matrix.goarch }}
out-dir: dist/freebsd-${{ matrix.goarch }}
output: ${{ env.PLUGIN_ID }}.so
flags: -ldflags=-s -w
x-flags: main.cpaSensitivePluginVersion=${{ steps.release_metadata.outputs.version }}
- name: Package plugin
run: |
set -euo pipefail
rm -f go-cross-bin.h "dist/freebsd-${{ matrix.goarch }}/${PLUGIN_ID}.h"
go run ./.github/scripts/package-release.go \
-library "dist/freebsd-${{ matrix.goarch }}/${PLUGIN_ID}.so" \
-archive "${ARCHIVE_NAME}" \
-checksum "${ARCHIVE_NAME}.sha256"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE_NAME }}
path: |
${{ env.ARCHIVE_NAME }}
${{ env.ARCHIVE_NAME }}.sha256
if-no-files-found: error
release:
name: Release
if: startsWith(github.ref, 'refs/tags/v')
needs:
- build
- build-windows-arm64
- build-freebsd
runs-on: ubuntu-24.04
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish GitHub release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
sort dist/*.sha256 > dist/checksums.txt
if gh release view "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
gh release upload "${GITHUB_REF_NAME}" dist/*.zip dist/checksums.txt --clobber --repo "${GITHUB_REPOSITORY}"
else
gh release create "${GITHUB_REF_NAME}" dist/*.zip dist/checksums.txt \
--repo "${GITHUB_REPOSITORY}" \
--verify-tag \
--title "${GITHUB_REF_NAME}" \
--notes "Automated release for ${GITHUB_REF_NAME}."
fi