-
Notifications
You must be signed in to change notification settings - Fork 157
115 lines (107 loc) · 4.34 KB
/
chart.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
name: Helm chart
on:
push:
branches:
- 'main'
paths:
- 'charts/**'
pull_request:
branches:
- 'main'
paths:
- 'charts/**'
workflow_dispatch:
env:
REGISTRY: ghcr.io
CHART_LOCATION: weaveworks/charts
permissions:
contents: read # for actions/checkout to fetch code
jobs:
helm-new-version:
runs-on: ubuntu-latest
outputs:
old-version: ${{ steps.old-version.outputs.version }}
new-version: ${{ steps.new-version.outputs.version }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Find new version
id: new-version
run: |
NEW_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml)
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Find old version
id: old-version
run: |
git checkout ${{ github.event.pull_request.base.sha || github.event.before }}
OLD_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml)
echo "version=$OLD_VERSION" >> $GITHUB_OUTPUT
helm-will-release:
runs-on: ubuntu-latest
needs: helm-new-version
if: github.event_name == 'pull_request' && needs.helm-new-version.outputs.old-version != needs.helm-new-version.outputs.new-version
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Find out if there's more changes to release
id: extra
run: |
last_revision=$(git blame ${{ github.event.pull_request.base.sha }} -L '/^version: [0-9.]\+$/,+1' charts/gitops-server/Chart.yaml | awk '{print $1}')
set +e
git log --exit-code $last_revision...${{ github.event.pull_request.base.sha }} charts/gitops-server
unreleased_commits=$?
if [[ $unreleased_commits == 1 ]]; then
echo "unreleased-commits=The last chart was last released in $last_revision and there have been other changes in the chart since" >> $GITHUB_OUTPUT
fi
- name: Let user know merging will cause a release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.WEAVE_GITOPS_BOT_ACCESS_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Merging this will release a new helm chart. ${{ steps.extra.outputs.unreleased-commits }}"
})
helm-release:
runs-on: ubuntu-latest
needs: helm-new-version
if: (github.event_name == 'push' && needs.helm-new-version.outputs.old-version != needs.helm-new-version.outputs.new-version) || github.event_name == 'workflow_dispatch'
permissions:
packages: write # needed for ghcr access
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Find new version
id: new_version
run: |
NEW_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml)
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Generate new chart
run: |
URL=https://helm.gitops.weave.works
mkdir helm-release
helm package charts/gitops-server/ -d helm-release
curl -O $URL/index.yaml
helm repo index helm-release --merge=index.yaml --url=$URL
- id: auth
uses: google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f # v2.1.7
with:
credentials_json: ${{ secrets.PROD_DOCS_GITOPS_UPLOAD }}
- id: upload-file
uses: google-github-actions/upload-cloud-storage@386ab77f37fdf51c0e38b3d229fad286861cc0d0 # v2.2.1
with:
path: helm-release
destination: helm.gitops.weave.works
parent: false
- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish chart as an OCI image
run: |
helm push helm-release/weave-gitops-${{ steps.new_version.outputs.version }}.tgz oci://${{ env.REGISTRY }}/${{ env.CHART_LOCATION }}