-
Notifications
You must be signed in to change notification settings - Fork 6
87 lines (73 loc) · 2.85 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
name: release
on:
push:
tags:
- "v*"
permissions:
# Required to publish a release
contents: write
# Necessary to push docker images to ghcr.io.
packages: write
# Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage)
id-token: write
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Build and publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "~1.22"
- name: Get Version
run: echo "version=$(./scripts/version.sh)" >> $GITHUB_OUTPUT
id: version
- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image
run: ./scripts/build.sh
env:
CI: true
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_ID_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Setup GCloud SDK
uses: "google-github-actions/setup-gcloud@v2"
- name: Publish Helm Chart
run: |
set -euo pipefail
version="$(./scripts/version.sh)"
./scripts/helm.sh --version $version
mkdir -p build/helm
cp "build/${version}.tgz" build/helm
gsutil cp gs://helm.coder.com/logstream-kube/index.yaml build/helm/index.yaml
helm repo index build/helm --url https://helm.coder.com/logstream-kube --merge build/helm/index.yaml
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/${version}.tgz gs://helm.coder.com/logstream-kube
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/index.yaml gs://helm.coder.com/logstream-kube
- name: Create and upload release
run: |
set -euo pipefail
version=${{ steps.version.outputs.version }}
# check if release already exists and match the version
if [[ $(gh release view $version --json name -q '.name' | cat) == $version ]]; then
echo "Release $version already exists"
exit 0
fi
echo "Creating release $version"
# if version contains -rc, publish as a pre-release and don't set as latest
if [[ $version == *-rc* ]]; then
gh release create $version -t $version --generate-notes --prerelease --latest=false --verify-tag build/${version}.tgz#helm.tar.gz
else
gh release create $version -t $version --generate-notes --verify-tag build/${version}.tgz#helm.tar.gz
fi
env:
GITHUB_TOKEN: ${{ github.token }}