Skip to content

Always enable CGO in release build workflow #6

Always enable CGO in release build workflow

Always enable CGO in release build workflow #6

Workflow file for this run

on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Upload Release Asset
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- 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
- name: Checkout code
uses: actions/checkout@v2
- name: Collect examples
run: |
tar czvf examples.tar.gz examples
- name: Upload Examples
id: upload-examples
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./examples.tar.gz
asset_name: examples.tar.gz
asset_content_type: application/octet-stream
build:
name: Build Release Binaries
runs-on: ${{ matrix.os }}
needs: create-release
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
arch:
- amd64
- arm64
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go
- name: Checkout code
uses: actions/checkout@v2
- name: Build project # This would actually build your project, using zip for an example artifact
run: |
go get -v -t -d ./...
mkdir bin
CGO_ENABLED=1 GOARCH=${arch} go build -v -ldflags "-X github.com/picoCTF/cmgr/cmgr.version=`git describe --tags`" -o bin ./...
cp LICENSE bin/LICENSE
cat NOTICE NOTICE.release > bin/NOTICE
cd bin && tar czvf cmgr.tar.gz cmgr cmgrd LICENSE NOTICE
env:
arch: ${{ matrix.arch }}
- name: Get OS/architecture suffix
id: suffix
run: |
echo "::set-output name=arch_suffix::`go version | cut -d ' ' -f 4,4 | cut -d '/' -f 1,1`_${arch}"
env:
arch: ${{ matrix.arch }}
- name: Upload Binaries
id: upload-binaries
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./bin/cmgr.tar.gz
asset_name: cmgr_${{ steps.suffix.outputs.arch_suffix }}.tar.gz
asset_content_type: application/octet-stream