-
Notifications
You must be signed in to change notification settings - Fork 14
85 lines (74 loc) · 3.3 KB
/
release.yml
File metadata and controls
85 lines (74 loc) · 3.3 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
on:
push:
branches: [main]
paths:
- "charts/postgrescluster/Chart.yaml"
workflow_dispatch:
name: release-postgrescluster
permissions:
contents: write
pull-requests: write
env:
HELM_VERSION: v3.18.3
jobs:
release-postgrescluster:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Get postgrescluster version
id: version
run: |
v=$(grep '^version:' charts/postgrescluster/Chart.yaml | sed 's/.*: *//' | tr -d ' \r')
echo "version=$v" >> $GITHUB_OUTPUT
- name: Skip if tag already exists
id: skip
run: |
git fetch --tags
if git rev-parse "postgrescluster-${{ steps.version.outputs.version }}" >/dev/null 2>&1; then echo "skip=true" >> $GITHUB_OUTPUT; else echo "skip=false" >> $GITHUB_OUTPUT; fi
- uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5
if: steps.skip.outputs.skip == 'false'
with:
version: ${{ env.HELM_VERSION }}
- name: Install chart-releaser
if: steps.skip.outputs.skip == 'false'
run: |
curl -sSLo cr.tar.gz "https://github.com/helm/chart-releaser/releases/download/v1.8.1/chart-releaser_1.8.1_linux_amd64.tar.gz"
tar -xzf cr.tar.gz -C /usr/local/bin
rm cr.tar.gz
cr version
- name: Configure git
if: steps.skip.outputs.skip == 'false'
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Package and publish postgrescluster chart
if: steps.skip.outputs.skip == 'false'
run: |
mkdir -p .cr-release-packages
helm package charts/postgrescluster --destination .cr-release-packages
cr upload \
--owner ${{ github.repository_owner }} \
--git-repo ${{ github.event.repository.name }} \
--package-path .cr-release-packages \
--commit "$(git rev-parse HEAD)" \
--skip-existing \
--token ${{ secrets.GITHUB_TOKEN }}
env:
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update Helm repo index
if: steps.skip.outputs.skip == 'false'
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
base_url="https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/releases/download/postgrescluster-${{ steps.version.outputs.version }}"
git clone --branch gh-pages --depth 1 "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}.git" gh-pages
helm repo index .cr-release-packages --merge gh-pages/index.yaml --url "$base_url"
cp .cr-release-packages/index.yaml gh-pages/index.yaml
cd gh-pages
git add index.yaml
git diff --staged --quiet || (git commit -m "Update index for postgrescluster-${{ steps.version.outputs.version }}" && git push)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}