forked from valkey-io/valkey-helm
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (76 loc) · 2.66 KB
/
Copy pathrelease.yml
File metadata and controls
87 lines (76 loc) · 2.66 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
name: Release Charts
on:
push:
branches:
- main
paths:
- 'valkey/Chart.yaml'
jobs:
check-version-change:
runs-on: ubuntu-latest
outputs:
version_changed: ${{ steps.check.outputs.version_changed }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2 # Need at least 2 commits to compare
- name: Check if version changed
id: check
run: |
# Get the version from the current commit
CURRENT_VERSION=$(grep '^version:' valkey/Chart.yaml | awk '{print $2}')
# Get the version from the previous commit
PREVIOUS_VERSION=$(git show HEAD~1:valkey/Chart.yaml | grep '^version:' | awk '{print $2}')
echo "Current version: $CURRENT_VERSION"
echo "Previous version: $PREVIOUS_VERSION"
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
echo "version_changed=true" >> $GITHUB_OUTPUT
echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION"
else
echo "version_changed=false" >> $GITHUB_OUTPUT
echo "Version unchanged"
fi
release:
needs: check-version-change
if: needs.check-version-change.outputs.version_changed == 'true'
permissions:
contents: write
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.7.0
with:
charts_dir: .
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_GENERATE_RELEASE_NOTES: true
- name: Push charts to GHCR
run: |
shopt -s nullglob
repo=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')
echo "${GITHUB_TOKEN}" | helm registry login ghcr.io/${repo} --username ${GITHUB_ACTOR} --password-stdin
for pkg in .cr-release-packages/*; do
if [ -z "${pkg:-}" ]; then
break
fi
echo "Pushing package - ${pkg} to ghcr.io repository - ${repo}"
helm push "${pkg}" "oci://ghcr.io/${repo}"
done
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"