-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (165 loc) · 5.47 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Release
on:
push:
tags:
- '*'
permissions:
contents: write
packages: write
env:
CHART_NAME: cardano-validator-watcher
CHART_DIRECTORY: charts
REGISTRY: oci://ghcr.io/kilnfi/charts
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
arch: [amd64, arm64]
runs-on: ${{ matrix.os }}
env:
CGO_ENABLED: 1
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Export Variables
id: export-variables
run: |
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
echo "os_name=linux" >> $GITHUB_OUTPUT
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
echo "os_name=darwin" >> $GITHUB_OUTPUT
elif [ "${{ matrix.os }}" = "windows-latest" ]; then
echo "os_name=windows" >> $GITHUB_OUTPUT
fi
- name: Install dependencies on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential
- name: Install dependencies on macOS
if: runner.os == 'macOS'
run: |
brew update
brew install sqlite
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23
- name: Build binary
run: |
mkdir -p dist
ARCH_NAME=${{ matrix.arch }}
OUTPUT_FILE="cardano-validator-watcher_${{ github.ref_name }}_${{ steps.export-variables.outputs.os_name }}_${ARCH_NAME}"
if [ "$OS_NAME" = "linux" ] && [ "$ARCH_NAME" = "arm" ]; then
echo "Building for Linux ARM with specific toolchain"
CC=arm-linux-gnueabihf-gcc \
CXX=arm-linux-gnueabihf-g++ \
CGO_ENABLED=1 \
GOOS=linux \
GOARCH=arm \
GOARM=7 \
go build -v -o dist/${OUTPUT_FILE} cmd/watcher/main.go
else
echo "Building for $OS_NAME $ARCH_NAME"
CGO_ENABLED=1 \
GOOS=$OS_NAME \
GOARCH=$ARCH_NAME \
go build -ldflags="-s -w" -o dist/${OUTPUT_FILE} cmd/watcher/main.go
fi
- name: List dist directory
run: ls -la dist/
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*.tar.gz
tag: ${{ github.ref_name }}
file_glob: true
binaries:
if: false
runs-on: ubuntu-latest
container:
image: docker.io/goreleaser/goreleaser-cross:v1.23
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
images:
if: false
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
name: Build & Push Container Images
with:
context: .
file: Dockerfile
labels: |-
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.name=cardano-validator-watcher"
org.opencontainers.image.version=${{ github.ref_name }}"
platforms: linux/amd64,linux/arm64
push: true
tags: |-
ghcr.io/${{ github.repository_owner }}/cardano-validator-watcher:${{ github.ref_name }}
ghcr.io/${{ github.repository_owner }}/cardano-validator-watcher:latest
helm-chart:
if: false
needs: images
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.16.4
- name: Verify Chart Version
run: |
TAG=$(echo ${{ github.ref_name }} | sed 's/v//')
CHART_VERSION=$(yq -r .version ${{ env.CHART_DIRECTORY }}/${{ env.CHART_NAME }}/Chart.yaml)
if [ "$TAG" != "${CHART_VERSION}" ]; then
echo "Version mismatch: release tag ${TAG} does not match Chart.yaml version ${CHART_VERSION}"
exit 1
fi
echo "CHART_VERSION=$CHART_VERSION" >> $GITHUB_ENV
- name: Helm Registry Login
run: |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ env.USERNAME }} --password-stdin
env:
USERNAME: kilnfi
- name: 'Helm Package'
id: helm-package
run: |
helm package ${{ env.CHART_DIRECTORY }}/${{ env.CHART_NAME }} --version $CHART_VERSION
- name: 'Helm Push'
run: |
helm push ./cardano-validator-watcher-$CHART_VERSION.tgz ${{ env.REGISTRY }}