Skip to content

Commit d2046a1

Browse files
authored
Improve release process (#1559)
Improve release process automating several actions: - After the container is published, an automatic PR will be created updating the chart - After the chart is published, an automatic PR will be created updating the Carvel package Signed-off-by: Alejandro Moreno <[email protected]>
1 parent c3cd4f1 commit d2046a1

File tree

3 files changed

+53
-10
lines changed

3 files changed

+53
-10
lines changed

.github/workflows/helm-release.yaml

+11-8
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,20 @@ jobs:
6565
IMGPKG_REGISTRY_USERNAME: ${{ github.actor }}
6666
IMGPKG_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
6767
run: |
68-
imgpkg push -b ghcr.io/${{ github.repository_owner }}/sealed-secrets-carvel:${{ env.chart_version }} -f .
68+
imgpkg push -b ghcr.io/${{ github.repository_owner }}/sealed-secrets-carvel:${{ env.chart_version }} -f . --json > output
69+
echo carvel_pkg=$(cat output | grep Pushed | cut -d "'" -f2 ) >> $GITHUB_ENV
6970
7071
- name: Update package.yaml
7172
run: |
7273
yq -i '.spec.version = "${{ env.chart_version }}"' carvel/package.yaml
7374
yq -i '.metadata.name = "sealedsecrets.bitnami.com.${{ env.chart_version }}"' carvel/package.yaml
74-
yq -i '.spec.template.spec.fetch.0.imgpkgBundle.image = "ghcr.io/${{ github.repository_owner }}/sealed-secrets-carvel:${{ env.chart_version }}"' carvel/package.yaml
75+
yq -i '.spec.template.spec.fetch.0.imgpkgBundle.image = "${{ env.carvel_pkg }}"' carvel/package.yaml
76+
git checkout -B 'release-carvel-${{ env.chart_version }}'
77+
git add carvel/package.yaml
78+
git commit -m 'Release carvel package ${{ env.chart_version }}'
79+
git push origin 'release-carvel-${{ env.chart_version }}'
7580
76-
# Commenting the git commit action
77-
#- name: Commit package.yaml
78-
#run: |
79-
#git add ./carvel/package.yaml
80-
#git commit -s -m 'Update package to version ${{ env.chart_version }}'
81-
#git push
81+
- name: Create PR
82+
run: gh pr create --fill --base main --repo $GITHUB_REPOSITORY
83+
env:
84+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish-release.yaml

+41-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ name: Publish Release
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
chart:
7+
description: 'Chart version (e.g. 2.11.3)'
8+
required: true
9+
type: string
510

611
jobs:
7-
build:
12+
release:
813
runs-on: ubuntu-latest
914
env:
1015
controller_dockerhub_image_name: docker.io/bitnami/sealed-secrets-controller
@@ -153,3 +158,38 @@ jobs:
153158
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
154159
TAG_CURRENT: ${{ steps.meta_kubeseal.outputs.tags }}
155160
COSIGN_REPOSITORY: ${{ env.kubeseal_ghcr_image_name }}/signs
161+
162+
chart-pr:
163+
needs: release
164+
runs-on: ubuntu-latest
165+
steps:
166+
- name: Checkout
167+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
168+
with:
169+
fetch-depth: 0
170+
171+
- name: Config Git
172+
run: |
173+
git config user.name "$GITHUB_ACTOR"
174+
git config user.email "[email protected]"
175+
176+
- name: Fetch Versions
177+
run: |
178+
echo NEW_VERSION=$(git describe --tags --match "v[0-9]*" --abbrev=0 | tr -d v) >> "$GITHUB_ENV"
179+
echo PREV_VERSION=$(grep appVersion helm/sealed-secrets/Chart.yaml | grep -o '[0-9.]*') >> "$GITHUB_ENV"
180+
181+
- name: Update Version
182+
run: |
183+
sed -i "s/version: .*/version: ${{ inputs.chart }}/" helm/sealed-secrets/Chart.yaml
184+
sed -i "s/appVersion: .*/appVersion: $NEW_VERSION/" helm/sealed-secrets/Chart.yaml
185+
sed -i "s/tag: .*/tag: $NEW_VERSION/" helm/sealed-secrets/values.yaml
186+
sed -i "s/\`$PREV_VERSION\`/\`$NEW_VERSION\`/" helm/sealed-secrets/README.md
187+
git checkout -B 'release-chart-${{ inputs.chart }}'
188+
git add helm/sealed-secrets/Chart.yaml helm/sealed-secrets/values.yaml helm/sealed-secrets/README.md
189+
git commit -m 'Release chart ${{ inputs.chart }}'
190+
git push origin 'release-chart-${{ inputs.chart }}'
191+
192+
- name: Create PR
193+
run: gh pr create --fill --base main --repo $GITHUB_REPOSITORY
194+
env:
195+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release
1+
name: Prepare Release
22

33
# Only release when a new GH release branch is pushed
44
on:

0 commit comments

Comments
 (0)