Merge pull request #24 from SerRichard/SerRichard-patch-7 #17
Workflow file for this run
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 | |
permissions: | |
contents: write | |
on: | |
push: | |
tags: | |
- '*.*.*' | |
jobs: | |
build: | |
name: Build Binaries | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [linux, darwin, windows] | |
goarch: [amd64] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.23' | |
- name: Get the Tag | |
id: get_tag | |
run: echo "TAG_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV | |
- name: Build Binary | |
run: | | |
mkdir -p dist/ | |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/proteus-${{ matrix.goos }}-${{ matrix.goarch }}-${{ env.TAG_NAME }} ./cli | |
- name: Compress Binary | |
if: matrix.goos != 'windows' | |
run: gzip dist/proteus-${{ matrix.goos }}-${{ matrix.goarch }}-${{ env.TAG_NAME }} | |
- name: Get the Release ID | |
id: get_release | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); | |
const tag = process.env.GITHUB_REF.replace('refs/tags/', ''); | |
const release = await github.repos.getReleaseByTag({ owner, repo, tag }); | |
return release.data.id; | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Release Asset (Linux and macOS) | |
if: matrix.goos != 'windows' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.get_release.outputs.result }}/assets?name=proteus-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }}.gz | |
asset_path: dist/proteus-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }}.gz | |
asset_name: proteus-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }}.gz | |
asset_content_type: application/gzip | |
- name: Upload Release Asset (Windows) | |
if: matrix.goos == 'windows' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.get_release.outputs.result }}/assets?name=proteus-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }}.exe | |
asset_path: dist/proteus-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }} | |
asset_name: proteus-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }}.exe | |
asset_content_type: application/octet-stream |