-
Notifications
You must be signed in to change notification settings - Fork 4
177 lines (149 loc) · 4.75 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
---
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
- release-branch.go1.23
- release-branch.go1.22
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: 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: Start BuildKit builder
run: make docker-up
- name: Build Docker images for PR
if: github.event_name == 'pull_request'
run: make docker-build
env:
# FIXME
DOCKER_PLATFORM: linux/amd64,linux/arm64
DOCKER_OUTPUT: type=image,push=true
DOCKER_TAG: aleksi/golang-tip:${{ env.GO_BRANCH }}
- name: Build Docker images for Docker Hub
if: github.event_name != 'pull_request'
run: make docker-build
env:
DOCKER_PLATFORM: linux/amd64,linux/arm64
DOCKER_OUTPUT: type=image,push=true
DOCKER_TAG: aleksi/golang-tip:${{ env.GO_BRANCH }}
- name: Build Docker images for ghcr.io
if: github.event_name != 'pull_request'
run: make docker-build
env:
DOCKER_PLATFORM: linux/amd64,linux/arm64
DOCKER_OUTPUT: type=image,push=true
DOCKER_TAG: ghcr.io/aleksi/golang-tip:${{ env.GO_BRANCH }}
# skip push for PRs
# move to `publish` job
# TODO https://github.com/AlekSi/golang-tip/issues/8
targz:
name: TarGz
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- macos-13
- macos-15
branch:
- master
- release-branch.go1.23
- release-branch.go1.22
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/[email protected]
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/[email protected]
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