Files
zurg/.github/workflows/build.yml
Ben Sarmiento dd6742a16f Use gha
2023-11-21 14:27:51 +01:00

79 lines
1.9 KiB
YAML

name: Build and Release with xgo
on: push
jobs:
build:
name: Build
runs-on: self-hosted
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Check out code
uses: actions/checkout@v4
- name: Cross-compile with xgo
uses: crazy-max/ghaction-xgo@v3
with:
xgo_version: latest
go_version: 1.21
dest: build
prefix: myapp
targets: windows/amd64,linux/amd64,linux/arm64,darwin/arm64
v: true
x: false
race: false
ldflags: -s -w
buildmode: default
trimpath: true
- name: Prepare artifacts
run: |
mkdir artifacts
mv github.com/debridmediamanager.com/zurg/cmd/zurg-* artifacts/
# New step for compressing artifacts
- name: Compress artifacts
run: |
tar -czvf artifacts.tar.gz -C artifacts .
- name: Upload artifacts to workflow
uses: actions/upload-artifact@v3
with:
name: compiled-binaries
path: artifacts.tar.gz
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: compiled-binaries
- name: Create 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 }}
draft: false
prerelease: false
# Ensure the asset_path matches the compressed file name
- name: Upload binaries to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts.tar.gz
asset_name: zurg-${{ github.run_number }}-${{ github.sha }}.tar.gz
asset_content_type: application/gzip