-
Notifications
You must be signed in to change notification settings - Fork 4
131 lines (108 loc) · 3.46 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
---
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:
jobs:
docker:
name: Docker
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
branch:
- master
- dev.boringcrypto
- dev.fuzz
- dev.go2go
runs-on: ${{ matrix.os }}
env:
GO_BRANCH: ${{ matrix.branch }}
steps:
- name: Checkout
uses: actions/checkout@v2
- 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: 15
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- macos-10.15
branch:
- master
- dev.boringcrypto
- dev.fuzz
- dev.go2go
runs-on: ${{ matrix.os }}
env:
GO_BRANCH: ${{ matrix.branch }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build .tar.gz file
run: make targz-build
- name: Set artifact name and path
run: |
echo ARTIFACT_NAME=${{ matrix.branch }}.$(go env GOOS)-$(go env GOARCH) >> $GITHUB_ENV
echo ARTIFACT_PATH=${{ matrix.branch }}.$(go env GOOS)-$(go env GOARCH).tar.gz >> $GITHUB_ENV
- name: Rename artifact
run: mv golang-tip.tar.gz ${{ env.ARTIFACT_PATH }}
- name: Upload artifact
uses: actions/[email protected]
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_PATH }}
if-no-files-found: error
publish:
name: Publish
needs: [docker, targz]
if: github.event_name != 'pull_request'
timeout-minutes: 15
runs-on: ubuntu-20.04
steps:
- name: Download artifacts
uses: actions/[email protected]
- name: List artifacts
run: ls -lR
- name: Publish artifacts
uses: marvinpinto/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: tip
prerelease: false
title: tip
files: |
**.tar.gz