Build #1308
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 | |
on: | |
schedule: | |
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events | |
# > Note: The schedule event can be delayed during periods of high loads of GitHub Actions workflow runs. | |
# > High load times include the start of every hour. To decrease the chance of delay, schedule your workflow to run at a different time of the hour. | |
- cron: '48 2 * * *' | |
# For weekly autoreleases | |
# TODO https://github.com/AlekSi/golang-tip/issues/5 | |
# - cron: '48 1 * * 0' | |
push: | |
branches: | |
- main | |
pull_request: | |
paths-ignore: ["**.md"] | |
jobs: | |
docker: | |
name: Docker | |
timeout-minutes: 20 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-22.04 | |
branch: | |
- master | |
runs-on: ${{ matrix.os }} | |
env: | |
GO_BRANCH: ${{ matrix.branch }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Start BuildKit builder | |
run: make docker-up | |
- name: Build Docker images | |
run: make docker-build | |
# skip push for PRs | |
# move to `publish` job | |
# TODO https://github.com/AlekSi/golang-tip/issues/8 | |
- name: Login into Docker registries | |
if: github.event_name != 'pull_request' | |
run: | | |
docker login --username aleksi --password ${{ secrets.DOCKERHUB_TOKEN }} | |
docker login ghcr.io --username aleksi --password ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Docker images | |
if: github.event_name != 'pull_request' | |
run: | | |
docker tag golang-tip:${{ env.GO_BRANCH }} aleksi/golang-tip:${{ env.GO_BRANCH }} | |
docker tag golang-tip:${{ env.GO_BRANCH }} ghcr.io/aleksi/golang-tip:${{ env.GO_BRANCH }} | |
docker push aleksi/golang-tip:${{ env.GO_BRANCH }} | |
docker push ghcr.io/aleksi/golang-tip:${{ env.GO_BRANCH }} | |
targz: | |
name: TarGz | |
timeout-minutes: 20 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-22.04 | |
- macos-12 | |
branch: | |
- master | |
goroot: | |
- /usr/local/go | |
- /tmp/golang-tip | |
runs-on: ${{ matrix.os }} | |
env: | |
GO_BRANCH: ${{ matrix.branch }} | |
GOROOT_FINAL: ${{ matrix.goroot }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build .tar.gz file | |
run: make targz-build | |
- name: Set artifact suffix | |
if: startsWith(env.GOROOT_FINAL, '/tmp/') | |
run: | | |
echo ARTIFACT_SUFFIX=.tmp >> $GITHUB_ENV | |
- name: Set artifact name | |
run: | | |
echo ARTIFACT_NAME=${{ env.GO_BRANCH }}.$(go env GOOS)-$(go env GOARCH)${{ env.ARTIFACT_SUFFIX }} >> $GITHUB_ENV | |
- name: Rename artifact | |
run: mv golang-tip.tar.gz ${{ env.ARTIFACT_NAME }}.tar.gz | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: ${{ env.ARTIFACT_NAME }}.tar.gz | |
if-no-files-found: error | |
publish: | |
name: Publish | |
needs: [docker, targz] | |
timeout-minutes: 10 | |
runs-on: ubuntu-22.04 | |
if: github.actor != 'dependabot[bot]' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Prepare files | |
run: | | |
go version | |
go run tipper.go all | |
- name: Publish artifacts | |
if: github.event_name != 'pull_request' | |
uses: marvinpinto/action-automatic-releases@v1.2.1 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
automatic_release_tag: tip | |
title: tip | |
prerelease: false | |
draft: false | |
files: | | |
**.tar.gz | |
*.txt | |
- name: Publish PR artifacts | |
if: github.event_name == 'pull_request' | |
uses: marvinpinto/action-automatic-releases@v1.2.1 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
automatic_release_tag: test | |
title: Test release by pull request; do not use | |
prerelease: true | |
draft: false | |
files: | | |
**.tar.gz | |
*.txt |