Skip to content

Refactor GitHub Actions workflow for release process: streamline jobs… #3

Refactor GitHub Actions workflow for release process: streamline jobs…

Refactor GitHub Actions workflow for release process: streamline jobs… #3

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Build for Multiple Platforms
run: |
mkdir -p releases
PLATFORMS=("windows/amd64" "linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64")
for platform in "${PLATFORMS[@]}"; do
OS=${platform%/*}
ARCH=${platform#*/}
output_name="releases/cp2p-${OS}-${ARCH}"
if [ $OS = "windows" ]; then
output_name="$output_name.exe"
fi
GOOS=$OS GOARCH=$ARCH go build -o "$output_name" .
done
- name: Generate Next Version
id: semver
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
dry_run: true
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.semver.outputs.new_tag }}
name: Release ${{ steps.semver.outputs.new_tag }}
body: ${{ steps.semver.outputs.changelog }}
files: |
releases/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}