-
Notifications
You must be signed in to change notification settings - Fork 22
106 lines (93 loc) · 4.01 KB
/
release.yml
File metadata and controls
106 lines (93 loc) · 4.01 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
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Release On Tag
on:
push:
tags:
# Only match tags that look like go module tags.
# This way we explicitly ignore our legacy tagging of the operator.
- '*/v*'
workflow_dispatch:
inputs:
ref_name:
description: "The ref name to process (e.g., 'operator/v1.2.3')"
required: false
default: ""
jobs:
release:
name: Create Release on GitHub
runs-on: ubuntu-latest
steps:
# for testing purposes and to allow updating of pre-existing releases,
# this workflow can be triggered by a tag being pushed or directly. This
# step normalized the possible inputs into a single variable.
- name: get ref
id: get_ref
run: |
if [[ -n "${{ inputs.ref_name }}" ]]; then
tag="${{ inputs.ref_name }}"
else
tag="${{ github.ref_name }}"
fi
echo "using ref name: $tag"
echo "ref_name=$tag" >> "$GITHUB_OUTPUT"
- name: checkout code
uses: actions/checkout@v4
with:
ref: ${{ steps.get_ref.outputs.ref_name }}
- uses: nixbuild/nix-quick-install-action@v30
with:
github_access_token: ${{ secrets.github_token }}
# cache the nix store.
- uses: nix-community/cache-nix-action@v6
with:
primary-key: nix-${{ runner.os }}-${{ runner.arch }}-${{ hashfiles('**/*.nix', '**/flake.lock') }}
restore-prefixes-first-match: nix-${{ runner.os }}-${{ runner.arch }}
- name: build release name
id: release_name
run: |
# turn refs into slightly friendlier names. e.g. operator/v1.2.3 -> operator: v1.2.3
release_name="$(echo "${{ steps.get_ref.outputs.ref_name }}" | sed 's|/v|: v|')"
echo "release_name=$release_name" >> "$GITHUB_OUTPUT"
- name: package helm chart
run: |
set -ex
tag="${{ steps.get_ref.outputs.ref_name }}"
# extract the directory from the tag (e.g., "operator" from "operator/v1.2.3")
dir="$(dirname "$tag")"
# search for chart.yaml in $dir or one directory deep (e.g., operator/chart)
chart_path=$(find "$dir" -maxdepth 2 -type f -name "Chart.yaml" | head -n 1)
# exit early if no chart.yaml file is found
if [[ -z "$chart_path" ]]; then
echo "no chart.yaml found for $tag. skipping step."
exit 0
fi
# Explicitly set the version based on the tag, stripping the leading
# v. This is done due to a mishap in managing the operator's version.
# All our charts specify `version` without a leading v but the
# operator's chart accidentally began doing so when binding version
# and appVersion.
# We enforce uniformity here, which retroactively corrects this
# issue.
version="$(basename "$tag")"
version="${version#v}"
echo "packaging chart at $chart_path"
helm package -u --version "$version" "$(dirname "$chart_path")"
- name: reformat change log
run: |
# Our CHANGE LOGS begin with '## VERSION - DATE', which is
# duplicative to include in the GH release body. tail -n +2 will
# remove the first line.
tail -n +2 .changes/${{ steps.get_ref.outputs.ref_name }}.md > RELEASE_BODY.md
# create github release and upload file
- name: create github release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.release_name.outputs.release_name }}
tag_name: ${{ steps.get_ref.outputs.ref_name }}
draft: false
make_latest: false
prerelease: ${{ contains(steps.get_ref.outputs.ref_name, '-alpha') || contains(steps.get_ref.outputs.ref_name, '-beta') }}
body_path: RELEASE_BODY.md
# if a chart was packaged, we'll upload it to this release preserving helm's naming convention.
files: |
./*.tgz
# todo(chrisseto) trigger an action in the charts repo that updates index.yaml