-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (101 loc) · 3.44 KB
/
build.yaml
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
name: Publish release
on:
push:
paths-ignore:
- '**.md'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
set-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: set version
id: set-version
run: |
echo Faking a Semantic Version
echo "version=1.$(date "+%Y%m%d%H%M%S")" >> ${GITHUB_OUTPUT}
test:
needs:
- set-version
runs-on: ubuntu-latest
steps:
- name: Checkout latest code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/[email protected]
with:
go-version-file: go.mod
- name: Test Go
run: |
go mod tidy -v
go test ./... -count=1 -coverprofile cover.out -short
release:
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- set-version
- test
runs-on: ubuntu-latest
steps:
- name: Checkout latest code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/[email protected]
with:
go-version-file: go.mod
- name: Create tag
run: |
git tag ${{ needs.set-version.outputs.version }}
- uses: navikt/github-app-token-generator@v1
id: get-homebrew-token
with:
private-key: ${{ secrets.NAIS_APP_PRIVATE_KEY }}
app-id: ${{ secrets.NAIS_APP_ID }}
repo: nais/homebrew-tap
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: v2.3.2
args: release --config .goreleaser.yaml --clean --verbose
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_PUSH_TOKEN: ${{ steps.get-homebrew-token.outputs.token }}
SCOOP_PUSH_TOKEN: ${{ steps.get-scoop-token.outputs.token }}
upload-gar:
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- set-version
- release
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@71f986410dfbc7added4569d411d040a91dc6935" # ratchet:google-github-actions/[email protected]
with:
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
service_account: "[email protected]"
token_format: "access_token"
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
with:
install_components: beta
- name: 'Upload new deb file to Google repository'
env:
VERSION: ${{ needs.set-version.outputs.version }}
run: |
echo "Version ${VERSION} was released, adding to PPA"
# Fetch latest deb
wget https://github.com/${{ github.repository }}/releases/download/${VERSION}/narc_${VERSION}_amd64.deb
wget https://github.com/${{ github.repository }}/releases/download/${VERSION}/narc_${VERSION}_arm64.deb
# Upload to GAR
gcloud --project nais-io beta artifacts apt upload nais-ppa --quiet --source narc_${VERSION}_amd64.deb --location europe-north1
gcloud --project nais-io beta artifacts apt upload nais-ppa --quiet --source narc_${VERSION}_arm64.deb --location europe-north1