-
Notifications
You must be signed in to change notification settings - Fork 1
107 lines (102 loc) · 3.18 KB
/
release.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
name: release
on:
push:
branches:
- main
jobs:
tag:
runs-on: ubuntu-latest
outputs:
changelog: ${{ steps.tag.outputs.changelog }}
tag: ${{ steps.tag.outputs.new_tag }}
version: ${{ steps.tag.outputs.new_version }}
date: ${{ steps.date.outputs.date }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Save the date
id: date
run: |
echo ::set-output name=date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Bump version and tag
uses: mathieudutour/[email protected]
id: tag
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
binaries:
name: build binaries
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux]
goarch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go
uses: WillAbides/[email protected]
with:
go-version: '1.19'
- name: Build
run: |
BINARY_NAME=scra-${{matrix.goos}}-${{matrix.goarch}}
GOOS=${{matrix.goos}} GOARCH=${{matrix.goarch}} go build -o $BINARY_NAME -v
- name: Save artifact
uses: actions/upload-artifact@v3
with:
name: scra-artifact
path: scra-*-*
retention-days: 1
container:
name: build container
runs-on: ubuntu-latest
needs: tag
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up buildx
uses: docker/setup-buildx-action@v1
- name: Build and push containers
uses: docker/build-push-action@v2
with:
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ github.repository }}:${{ needs.tag.outputs.tag }}
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.created=${{ needs.tag.outputs.date }}
org.opencontainers.image.version=${{ needs.tag.outputs.tag }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
release:
needs:
- tag
- container
- binaries
runs-on: ubuntu-latest
steps:
- name: Restore artifact
uses: actions/download-artifact@v3
with:
name: scra-artifact
- name: Create checksums
run: |
sha256sum scra-*-* | tee scra.sha256
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.tag.outputs.tag }}
name: Release ${{ needs.tag.outputs.version }}
body: |
Changes in this release:
${{ needs.tag.outputs.changelog }}
Docker image: `ghcr.io/${{ github.repository }}:${{ needs.tag.outputs.tag }}`
files: scra-*-*,scra.sha256