forked from maybe-finance/maybe
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (80 loc) · 3.03 KB
/
chart-release.yml
File metadata and controls
93 lines (80 loc) · 3.03 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
88
89
90
91
92
93
name: Chart Release
on:
push:
tags:
- 'chart-v*'
workflow_dispatch:
permissions:
contents: write
jobs:
prepare_release:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.tag.outputs.tag_name }}
chart_version: ${{ steps.tag.outputs.chart_version }}
app_version: ${{ steps.tag.outputs.app_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve chart release tag
id: tag
shell: bash
run: |
set -euo pipefail
# Read the canonical version from the Rails app (single source of truth)
APP_SEMVER=$(grep -oP '"\K[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?' config/initializers/version.rb | head -n 1 || true)
if [ -z "$APP_SEMVER" ]; then
echo "::error::Could not extract version from config/initializers/version.rb"
exit 1
fi
echo "App version from version.rb: $APP_SEMVER"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
# Use the app version as the chart version (monorepo: versions stay in sync)
TAG_NAME="chart-v${APP_SEMVER}"
if git rev-parse "refs/tags/${TAG_NAME}" >/dev/null 2>&1; then
echo "::error::Tag ${TAG_NAME} already exists. Bump the version in config/initializers/version.rb and charts/sure/Chart.yaml first."
exit 1
fi
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
if ! git tag "$TAG_NAME"; then
echo "::error::Failed to create tag ${TAG_NAME}"
exit 1
fi
if ! git push origin "$TAG_NAME"; then
echo "::error::Failed to push tag ${TAG_NAME} to origin"
exit 1
fi
else
TAG_NAME="${GITHUB_REF_NAME}"
fi
CHART_VERSION="${TAG_NAME#chart-v}"
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
echo "chart_version=$CHART_VERSION" >> "$GITHUB_OUTPUT"
echo "app_version=$APP_SEMVER" >> "$GITHUB_OUTPUT"
publish_chart:
needs: prepare_release
uses: ./.github/workflows/helm-publish.yml
with:
chart_version: ${{ needs.prepare_release.outputs.chart_version }}
app_version: ${{ needs.prepare_release.outputs.app_version }}
update_gh_pages: true
secrets: inherit
release:
needs: [prepare_release, publish_chart]
runs-on: ubuntu-latest
steps:
- name: Download Helm chart artifact
uses: actions/download-artifact@v4
with:
name: helm-chart-package
path: ${{ runner.temp }}/helm-artifacts
- name: Create chart GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare_release.outputs.tag_name }}
name: ${{ needs.prepare_release.outputs.tag_name }}
generate_release_notes: true
files: ${{ runner.temp }}/helm-artifacts/*.tgz