-
Notifications
You must be signed in to change notification settings - Fork 13
102 lines (92 loc) · 3.59 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
name: "Release"
on:
push:
tags:
- v*
jobs:
release:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@master
- uses: actions/setup-go@v5
with:
go-version: '1.23.1'
- name: Unit tests
run: go test -v ./...
- run: |
export VERSION=${GITHUB_REF##*/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
export CURRENT_DATE=$(date --iso-8601=seconds)
echo "RELEASE_DATE=$CURRENT_DATE" >> $GITHUB_ENV
export CHART_RELEASE_VERSION=${VERSION:1}
echo "CHART_RELEASE_VERSION=$CHART_RELEASE_VERSION" >> $GITHUB_ENV
- name: Building binaries
run: |
go mod download
mkdir binaries
cd cmd/prometheus-multi-tenant-proxy
GOOS=darwin GOARCH=amd64 go build -o prometheus-multi-tenant-proxy -ldflags="-X 'main.version=${{ env.RELEASE_VERSION }}' -X 'main.commit=${{ github.sha }}' -X 'main.date=${{ env.RELEASE_DATE }}'"
mv prometheus-multi-tenant-proxy ../../binaries/prometheus-multi-tenant-proxy-darwing-amd64
GOOS=linux GOARCH=amd64 go build -o prometheus-multi-tenant-proxy -ldflags="-X 'main.version=${{ env.RELEASE_VERSION }}' -X 'main.commit=${{ github.sha }}' -X 'main.date=${{ env.RELEASE_DATE }}'"
mv prometheus-multi-tenant-proxy ../../binaries/prometheus-multi-tenant-proxy-linux-amd64
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v6
with:
file: ./build/package/Dockerfile
context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64
pull: true
no-cache: true
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.RELEASE_VERSION }}
ghcr.io/${{ github.repository }}:latest
build-args: |
RELEASE_DATE=${{ env.RELEASE_DATE }}
VERSION=${{ env.RELEASE_VERSION }}
COMMIT=${{ github.sha }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
release_name: Release ${{ env.RELEASE_VERSION }}
body: |
Release ${{ env.RELEASE_VERSION }}
- name: Upload Linux release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./binaries/prometheus-multi-tenant-proxy-linux-amd64
asset_name: prometheus-multi-tenant-proxy-linux-amd64
asset_content_type: application/octet-stream
- name: Upload Darwin release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./binaries/prometheus-multi-tenant-proxy-darwing-amd64
asset_name: prometheus-multi-tenant-proxy-darwing-amd64
asset_content_type: application/octet-stream
- name: Publish Helm charts
uses: stefanprodan/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
charts_dir: deployments/kubernetes/helm
chart_version: ${{ env.CHART_RELEASE_VERSION }}
app_version: ${{ env.RELEASE_VERSION }}