-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (89 loc) · 3.16 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
88
89
90
name: Release
on:
release:
types:
- published
jobs:
# step 1) take the sha we are on, and push a tag matching the release name
promote_tag:
name: 'Promote Tag'
timeout-minutes: 7
runs-on: 'ubuntu-latest'
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"
# get the associated sha
- name: Get Existing Tag
run: echo "tag=sha-$(git rev-parse --short=7 HEAD)" >> $GITHUB_OUTPUT
id: current-tag
# login to the registry
- name: Log into registry
timeout-minutes: 5
uses: docker/login-action@b4bedf8053341df3b5a9f9e0f2cf4e79e27360c6
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# get the version from gradle, this is used in the chart
# we need to ensure this tag exists before publishing the chart
- name: Output Gradle Version
id: version
run: |
echo "New version will be $(./gradlew --console=plain -q printVersion)"
echo "version=$(./gradlew --console=plain -q printVersion | head -n 3 | tail -1)" >> $GITHUB_OUTPUT
# retag, this is same repo but could be tweaked to push to a prod repo
- name: Promote Tag
run: |
skopeo copy --all docker://ghcr.io/${{ github.repository }}:${{ steps.current-tag.outputs.tag }} \
docker://ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}
# step 2) build and publish the helm chart to an oci repo.
publish_chart:
name: 'Publish Chart'
runs-on: 'ubuntu-latest'
timeout-minutes: 7
needs:
- promote_tag
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"
# login to the registry for oci pushes
- name: Log into registry
timeout-minutes: 5
uses: docker/login-action@b4bedf8053341df3b5a9f9e0f2cf4e79e27360c6
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# use gradle tasks to build the chart
- name: Execute Gradle Tasks
uses: gradle/gradle-build-action@v2.8.0
env:
HELM_REPO_PATH: "${{ github.repository_owner }}/helm"
HELM_REPO_USERNAME: "${{ github.actor }}"
HELM_REPO_PASSWORD: "${{ secrets.GITHUB_TOKEN }}"
with:
gradle-version: 8.3
arguments: k8sResource k8sHelm k8sHelmPush
# # we've already logged into the registry use helm to push, in the future use k8sHelmPush task
# - name: Helm Publish
# run: |
# cd build/jkube/helm/$(./gradlew --console=plain -q printProjectName)/kubernetes/ && \
# helm package . && \
# helm push *.tgz oci://ghcr.io/${{ github.repository_owner }}/helm