-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (66 loc) · 2.94 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
name: Artifacts
on:
pull_request:
branches:
- main
push:
tags:
- v*
branches:
- '**'
jobs:
artifacts:
name: Goreleaser release
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
container:
image: docker.io/goreleaser/goreleaser-cross:v1.22.4
options: --privileged
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out the code
uses: actions/checkout@v4
with:
fetch-depth: 0
# https://github.com/actions/checkout/issues/766
- name: Add repository directory to the git global config as a safe directory
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Fetch all tags
run: git fetch --force --tags
- name: Login to registry
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/')
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Login to registry
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Run Goreleaser release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: goreleaser release --clean --verbose
- name: Run Goreleaser snapshot
run: |
goreleaser release --clean --verbose --snapshot
- name: Set snapshot tag
id: vars
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/')
run: |
echo "tag=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "git_tag=v0.0.0" >> $GITHUB_OUTPUT
# Use this again once we have a frist release
# echo "git_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
- name: Push snapshot images
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/')
run: |
docker tag ghcr.io/polarsignals/gpu-metrics-agent:${{ steps.vars.outputs.git_tag }}-amd64 ghcr.io/polarsignals/gpu-metrics-agent:${{ steps.vars.outputs.tag }}-amd64
docker push ghcr.io/polarsignals/gpu-metrics-agent:${{ steps.vars.outputs.tag }}-amd64
docker manifest create ghcr.io/polarsignals/gpu-metrics-agent:${{ steps.vars.outputs.tag }} --amend ghcr.io/polarsignals/gpu-metrics-agent:${{ steps.vars.outputs.tag }}-amd64
docker manifest annotate ghcr.io/polarsignals/gpu-metrics-agent:${{ steps.vars.outputs.tag }} ghcr.io/polarsignals/gpu-metrics-agent:${{ steps.vars.outputs.tag }}-amd64 --os linux --arch amd64
docker manifest push ghcr.io/polarsignals/gpu-metrics-agent:${{ steps.vars.outputs.tag }}