Skip to content

build

build #68

Workflow file for this run

name: Build and Release
on:
push:
branches:
- master
tags:
- 'v*.*.*' # Match version tags, e.g., v1.0.0
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
include:
- goos: linux
goarch: amd64
dir: dist
extension: "-linux-amd64"
- goos: linux
goarch: arm64
dir: dist
extension: "-linux-arm64"
- goos: windows
goarch: amd64
dir: dist
extension: "-windows-amd64.exe"
- goos: windows
goarch: arm64
dir: dist
extension: "-windows-arm64.exe"
- goos: darwin
goarch: amd64
dir: dist
extension: "-darwin-amd64"
- goos: darwin
goarch: arm64
dir: dist
extension: "-darwin-arm64"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '^1.22'
cache: false
- name: Install dependencies
run: go mod tidy
- name: Build
run: |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o ${{ matrix.dir }}/rune${{ matrix.extension }} ./dist
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: rune-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist
- name: Log Upload Artifacts
run: |
echo "Uploaded artifacts:"
ls -l dist/
release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: List Downloaded Artifacts
run: |
echo "Listing contents of the artifacts directory:"
ls -R artifacts
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Release notes for version ${{ github.ref }}.
draft: false
prerelease: false
- name: Debug Release Info
run: |
echo "Release tag: ${{ github.ref }}"
echo "Upload URL: ${{ steps.create_release.outputs.upload_url }}"
- name: Upload Release Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
declare -A paths
paths[linux/amd64]=artifacts/rune-linux-amd64/rune-linux-amd64
paths[linux/arm64]=artifacts/rune-linux-arm64/rune-linux-arm64
paths[windows/amd64]=artifacts/rune-windows-amd64/rune-windows-amd64.exe
paths[windows/arm64]=artifacts/rune-windows-arm64/rune-windows-arm64.exe
paths[darwin/amd64]=artifacts/rune-darwin-amd64/rune-darwin-amd64
paths[darwin/arm64]=artifacts/rune-darwin-arm64/rune-darwin-arm64
for key in "${!paths[@]}"; do
file_path="${paths[$key]}"
if [ -f "$file_path" ]; then
echo "Uploading $file_path"
gh release upload ${{ github.ref }} "$file_path" --clobber --repo ${{ github.repository }}
else
echo "File $file_path does not exist"
fi
done