-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (120 loc) · 3.71 KB
/
release.yaml
File metadata and controls
138 lines (120 loc) · 3.71 KB
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
name: Release
on:
push:
branches:
- master
permissions:
contents: write
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/operator
jobs:
release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
released: ${{ steps.get-version.outputs.released }}
permissions:
contents: write
issues: write
pull-requests: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Install dependencies
run: |
npm init -y
npm install --save-dev \
semantic-release \
@semantic-release/git \
@semantic-release/changelog \
@semantic-release/github \
@semantic-release/exec
- name: Semantic Release
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
- name: Get version
id: get-version
run: |
if [ -f .VERSION ]; then
echo "released=true" >> $GITHUB_OUTPUT
echo "version=$(cat .VERSION)" >> $GITHUB_OUTPUT
else
echo "released=false" >> $GITHUB_OUTPUT
echo "version=" >> $GITHUB_OUTPUT
fi
build-and-push:
needs: release
if: needs.release.outputs.released == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
publish-helm:
needs: [release, build-and-push]
if: needs.release.outputs.released == 'true'
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- name: Install Helm
uses: azure/setup-helm@v3
- name: Update Chart version
uses: mikefarah/yq@master
with:
cmd: yq -i '.version = "${{ needs.release.outputs.version }}"' 'charts/github-deploy-key-operator/Chart.yaml'
- name: Update Chart appVersion
uses: mikefarah/yq@master
with:
cmd: yq -i '.appVersion = "${{ needs.release.outputs.version }}"' 'charts/github-deploy-key-operator/Chart.yaml'
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Helm chart to OCI registry
run: |
helm package charts/github-deploy-key-operator
helm push github-deploy-key-operator-${{ needs.release.outputs.version }}.tgz oci://${{ env.REGISTRY }}/${{ github.repository }}