I often "publish" artifacts internally in github actions with the actions/upload-artifact action. https://github.com/actions/upload-artifact
//.github/workflows/main.yml
name: Main
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Test
run: go test -v ./...
- name: Build Discover Command
run: go build -o discover cmd/discover/main.go
- name: Upload Build Artifacts
uses: actions/upload-artifact@v2
with:
name: discover
path: discover
For internal tooling we often publish tagged artifacts to releases on the repo using a workflow that is triggered when someone creates a release. The creation of the release makes a new tag and triggers the build.//.github/workflows/release.yml
name: Release
on:
release:
types:
- published
jobs:
build:
runs-on: self-hosted
env:
GOPRIVATE: "github.com/OUR-ORG-NAME/\*"
NAME: deploy-${{ github.event.release.tag_name }}-${{ matrix.GOOS }}-${{ matrix.GOARCH }}${{ matrix.EXTENSION }}
strategy:
matrix:
GOOS: [ windows, linux, darwin ]
GOARCH: [ amd64, 386 ]
exclude:
# excludes 32bit on macOS
- GOOS: darwin
GOARCH: 386
include:
# includes a new variable for windows builds
- GOOS: windows
EXTENSION: ".exe"
steps:
# Runs a single command using the runners shell
- name: Print Info
run: echo '${{ toJSON(github.event.release) }}'
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
# From https://github.com/mvdan/github-actions-golang/blob/master/README.md
- name: Configure git for private modules
run: |
git config --global \
url."https://${{ secrets.GHUSER }}:${{ secrets.GHTOKEN }}@github.com".insteadOf \
"https://github.com"
- name: Build ${{ env.NAME }} Command
run: |
GOOS=${{ matrix.GOOS }} \
GOARCH=${{ matrix.GOARCH }} \
go build -o ${{ env.NAME }} cmd/main.go
- name: Upload Release Asset - ${{ matrix.GOOS }} / ${{ matrix.GOARCH }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ env.NAME }}
asset_name: ${{ env.NAME }}
asset_content_type: application/octet-stream
edit: code formatting