Automatically publishing your build artifacts
I often &quot;publish&quot; artifacts internally in github actions with the actions&#x2F;upload-artifact action. <a href="https:&#x2F;&#x2F;github.com&#x2F;actions&#x2F;upload-artifact" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;actions&#x2F;upload-artifact</a><p>&#x2F;&#x2F;.github&#x2F;workflows&#x2F;main.yml<p><pre><code>  name: Main

  on:
    push:
      branches: [ main ]
    pull_request:
      branches: [ main ]

  jobs:

    build:
      runs-on: self-hosted
      steps:
      - uses: actions&#x2F;checkout@v2

      - name: Set up Go
        uses: actions&#x2F;setup-go@v2
        with:
          go-version: 1.16

      - name: Test
        run: go test -v .&#x2F;...

      - name: Build Discover Command
        run: go build -o discover cmd&#x2F;discover&#x2F;main.go

      - name: Upload Build Artifacts
        uses: actions&#x2F;upload-artifact@v2
        with:
          name: discover
          path: discover

</code></pre>
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.<p>&#x2F;&#x2F;.github&#x2F;workflows&#x2F;release.yml<p><pre><code>  name: Release

  on:
    release:
      types:
        - published

  jobs:
    build:
      runs-on: self-hosted
      env:
        GOPRIVATE: &quot;github.com&#x2F;OUR-ORG-NAME&#x2F;\*&quot;
        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: &quot;.exe&quot;
      steps:
        # Runs a single command using the runners shell
        - name: Print Info
          run: echo &#x27;${{ toJSON(github.event.release) }}&#x27;

        - uses: actions&#x2F;checkout@v2

        - name: Set up Go
          uses: actions&#x2F;setup-go@v2
          with:
            go-version: 1.16

        # From https:&#x2F;&#x2F;github.com&#x2F;mvdan&#x2F;github-actions-golang&#x2F;blob&#x2F;master&#x2F;README.md
        - name: Configure git for private modules
          run: |
            git config --global \
            url.&quot;https:&#x2F;&#x2F;${{ secrets.GHUSER }}:${{ secrets.GHTOKEN }}@github.com&quot;.insteadOf \
            &quot;https:&#x2F;&#x2F;github.com&quot;
        - name: Build ${{ env.NAME }} Command
          run: |
            GOOS=${{ matrix.GOOS }} \
            GOARCH=${{ matrix.GOARCH }} \
            go build -o ${{ env.NAME }} cmd&#x2F;main.go
        - name: Upload Release Asset - ${{ matrix.GOOS }} &#x2F; ${{ matrix.GOARCH }}
          uses: actions&#x2F;upload-release-asset@v1
          env:
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          with:
            upload_url: ${{ github.event.release.upload_url }}
            asset_path: .&#x2F;${{ env.NAME }}
            asset_name:   ${{ env.NAME }}
            asset_content_type: application&#x2F;octet-stream
</code></pre>
edit: code formatting