bump version -> v0.1.48 #136
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: rune | |
extension: "-linux-amd64" | |
- goos: linux | |
goarch: arm64 | |
dir: rune | |
extension: "-linux-arm64" | |
- goos: windows | |
goarch: amd64 | |
dir: rune | |
extension: "-windows-amd64.exe" | |
- goos: windows | |
goarch: arm64 | |
dir: rune | |
extension: "-windows-arm64.exe" | |
- goos: darwin | |
goarch: amd64 | |
dir: rune | |
extension: "-darwin-amd64" | |
- goos: darwin | |
goarch: arm64 | |
dir: rune | |
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 }} ./rune | |
- name: Upload Build Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rune-${{ matrix.goos }}-${{ matrix.goarch }} | |
path: rune | |
- name: Log Upload Artifacts | |
run: | | |
echo "Uploaded artifacts:" | |
ls -l rune/ | |
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: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
name: Release ${{ github.ref_name }} | |
body: Release of version ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Assets | |
uses: actions/github-script@v7 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
script: | | |
const fs = require('fs').promises; | |
const path = require('path'); | |
const artifacts = [ | |
'artifacts/rune-linux-amd64/rune-linux-amd64', | |
'artifacts/rune-linux-arm64/rune-linux-arm64', | |
'artifacts/rune-windows-amd64/rune-windows-amd64.exe', | |
'artifacts/rune-windows-arm64/rune-windows-arm64.exe', | |
'artifacts/rune-darwin-amd64/rune-darwin-amd64', | |
'artifacts/rune-darwin-arm64/rune-darwin-arm64' | |
]; | |
for (const artifact of artifacts) { | |
try { | |
const data = await fs.readFile(artifact); | |
const fileName = path.basename(artifact); | |
await github.rest.repos.uploadReleaseAsset({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: ${{ steps.create_release.outputs.id }}, | |
name: fileName, | |
data: data | |
}); | |
console.log(`Uploaded ${fileName}`); | |
} catch (error) { | |
console.error(`Error uploading ${artifact}: ${error.message}`); | |
} | |
} |