Skip to content

Merge pull request #1 from Arlowen/codex/openapi-cli-sdk-parity #4

Merge pull request #1 from Arlowen/codex/openapi-cli-sdk-parity

Merge pull request #1 from Arlowen/codex/openapi-cli-sdk-parity #4

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run tests
run: go test ./...
- name: Build release assets
run: |
set -euo pipefail
mkdir -p dist
VERSION="${GITHUB_REF_NAME:-dev}"
for target in \
"darwin amd64" \
"darwin arm64" \
"linux amd64" \
"linux arm64"
do
read -r goos goarch <<<"$target"
workdir="$(mktemp -d)"
asset_name="cloudcanal_${goos}_${goarch}.tar.gz"
GOOS="$goos" GOARCH="$goarch" CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o "$workdir/cloudcanal" ./cmd/cloudcanal
tar -C "$workdir" -czf "dist/$asset_name" cloudcanal
rm -rf "$workdir"
done
(
cd dist
sha256sum cloudcanal_*.tar.gz > checksums.txt
)
- name: Generate release notes from CHANGELOG
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
output="dist/release-notes.md"
awk -v version="$version" '
$0 ~ "^## \\[" version "\\]" { in_section = 1 }
/^## \[/ && in_section && $0 !~ "^## \\[" version "\\]" { exit }
in_section { print }
' CHANGELOG.md > "$output"
if [[ ! -s "$output" ]]; then
echo "Release notes for version ${version} not found in CHANGELOG.md" >&2
exit 1
fi
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/cloudcanal_*.tar.gz
dist/checksums.txt
body_path: dist/release-notes.md