Skip to content

update workflow

update workflow #28

Workflow file for this run

name: Build
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: linux
extension: ""
- goos: linux
goarch: arm64
dir: linux
extension: ""
- goos: windows
goarch: amd64
dir: win
extension: ".exe"
- goos: windows
goarch: arm64
dir: win
extension: ".exe"
- goos: darwin
goarch: amd64
dir: macos
extension: ""
- goos: darwin
goarch: arm64
dir: macos
extension: ""
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: |
mkdir -p ${{ matrix.dir }}
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o ${{ matrix.dir }}/rune-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }} ./dist
- name: Archive Artifacts
run: |
tar -czvf ${{ matrix.dir }}/rune-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz -C ${{ matrix.dir }} rune-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }}
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: rune-${{ matrix.goos }}-${{ matrix.goarch }}
path: ${{ matrix.dir }}/rune-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
path: ./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: Upload Release Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for file in ./artifacts/**/*.tar.gz; do
filename=$(basename "$file")
gh release upload ${{ github.ref }} "$file" --clobber --repo ${{ github.repository }}
done