-
Notifications
You must be signed in to change notification settings - Fork 5
112 lines (103 loc) · 4.31 KB
/
release.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
on:
push:
tags:
- 'v*'
name: Handle Release
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- name: Get tag version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Build Asset (linux/amd64)
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'" -o bin/prometheus-aws-discovery-linux-amd64 ./cmd/prometheus-aws-discovery/...
- name: Build Asset (darwin/amd64)
run: CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'" -o bin/prometheus-aws-discovery-darwin-amd64 ./cmd/prometheus-aws-discovery/...
- name: Build Asset (linux/arm64)
run: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'" -o bin/prometheus-aws-discovery-linux-arm64 ./cmd/prometheus-aws-discovery/...
- name: Build Asset (darwin/arm64)
run: CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'" -o bin/prometheus-aws-discovery-darwin-arm64 ./cmd/prometheus-aws-discovery/...
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
body: |
Build also available as docker image:
`daspawnw/prometheus-aws-discovery:${{ steps.get_version.outputs.VERSION }}`
- name: Upload Release Asset (linux/amd64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/prometheus-aws-discovery-linux-amd64
asset_name: prometheus-aws-discovery-linux-amd64
asset_content_type: application/x-executable
- name: Upload Release Asset (darwin/amd64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/prometheus-aws-discovery-darwin-amd64
asset_name: prometheus-aws-discovery-darwin-amd64
asset_content_type: application/x-mach-binary
- name: Upload Release Asset (linux/arm64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/prometheus-aws-discovery-linux-arm64
asset_name: prometheus-aws-discovery-linux-arm64
asset_content_type: application/x-executable
- name: Upload Release Asset (darwin/arm64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/prometheus-aws-discovery-darwin-arm64
asset_name: prometheus-aws-discovery-darwin-arm64
asset_content_type: application/x-mach-binary
docker:
name: Docker Push (GHCR & public ECR)
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
packages: write
needs: Release
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Set output
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Docker publish
uses: daspawnw/docker-multi-build-push-action@master
with:
platforms: "linux/amd64,linux/arm64"
docker-tag: "${{ steps.vars.outputs.tag }}"
ghcr-enabled: "true"
ghcr-token: "${{ secrets.GITHUB_TOKEN }}"
ecr-enabled: "true"
ecr-role-to-assume: "${{ secrets.AWS_PUBLIC_ECR_ARN }}"
ecr-repository-url: "public.ecr.aws/l2l6k4u5/prometheus-aws-discovery"