Skip to content

release

release #34

Workflow file for this run

name: release
permissions:
contents: read
on:
workflow_dispatch:
inputs:
version:
description: "Version to release (e.g., v1.0.0)"
required: true
type: string
push:
tags:
- v*.*.*
jobs:
release:
name: Create and Publish Release
runs-on: ubuntu-latest
steps:
- name: Set up Go
id: go
uses: actions/setup-go@v3
with:
go-version: 1.24
- name: Checkout code
uses: actions/checkout@v3
- name: Get Repo Name
id: get_repo_name
run: |
# Extract repo name from GITHUB_REPOSITORY variable
repo_fullname="${{ github.repository }}"
repo_name="${repo_fullname##*/}"
echo "REPO_NAME=${repo_name}" >> $GITHUB_ENV
- name: Get Tag Name
id: get_tag_name
run: |
# Extract tag from repo
tag_name="${{ github.ref_name }}"
echo "TAG_NAME=${tag_name}" >> $GITHUB_ENV
- name: Create Release
run: |
git archive --format tar.gz --prefix="${REPO_NAME}/" --output "${REPO_NAME}-${TAG_NAME}.tar.gz" HEAD
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
- name: Compile
run: |
mkdir -p release
for os in linux darwin windows; do
for arch in amd64 386 arm arm64; do
# Skip unsupported darwin combinations
if [[ "$os/$arch" != "darwin/arm" && "$os/$arch" != "darwin/386" ]]; then
executable="executor"
archive_name="executor_${os}-${arch}_${TAG_NAME//./_}"
# .exe and zip for windows, tar.gz for others
if [ "$os" = "windows" ]; then
executable="${executable}.exe"
archive_name="${archive_name}.zip"
else
archive_name="${archive_name}.tar.gz"
fi
echo "Building $os/$arch --> $executable ${TAG_NAME}"
GOOS=$os GOARCH=$arch go build -ldflags="-s -w -X main.version=${TAG_NAME}" -o "release/$executable" main.go
echo "Compressing $executable --> $archive_name"
if [ "$os" = "windows" ]; then
(cd release && zip -r "$archive_name" "$executable")
else
tar -C release -czf "release/$archive_name" "$executable"
fi
if [[ "$os" = "darwin" && "$arch" = "arm64" ]]; then
pushd release
bottle_dir="bottle/executor/${TAG_NAME#v}/bin"
mkdir -p "$bottle_dir"
cp "$executable" "$bottle_dir/."
tar -C bottle -czf "executor-${TAG_NAME#v}.arm64_ventura.bottle.tar.gz" executor
rm -Rf bottle
popd
fi
if [[ "$os" = "darwin" && "$arch" = "amd64" ]]; then
pushd release
bottle_dir="bottle/executor/${TAG_NAME#v}/bin"
mkdir -p "$bottle_dir"
cp "$executable" "$bottle_dir/."
tar -C bottle -czf "executor-${TAG_NAME#v}.ventura.bottle.tar.gz" executor
rm -Rf bottle
popd
fi
rm "release/$executable"
fi
done
done
- name: Generate SHA256 sums
run: |
cd release
sha256sum * > SHA256SUMS.txt
cat SHA256SUMS.txt
- name: Upload Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.PUBLISH_TOKEN }}
files: |
${{ github.event.repository.name }}-${{ steps.get_tag_name.outputs.TAG_NAME }}.tar.gz
release/*