-
-
Notifications
You must be signed in to change notification settings - Fork 184
130 lines (112 loc) · 4.54 KB
/
release-please.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
env:
PUBLISHABLE_ITEMS: '["charts/pihole"]'
name: release-please
jobs:
# since there is currently only one chart to be released I leave it like this for now
# for multiple charts this would have to be more dynamic
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: ✨ Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: google-github-actions/release-please-action@v4
name: 🙌 Prepare release
id: release-please
with:
token: ${{ secrets.CR_TOKEN }}
- name: 🐛 Dump Release Please Output
env:
RELEASE_PLEASE_OUTPUT: ${{ toJson(steps.release-please.outputs) }}
run: |
echo "$RELEASE_PLEASE_OUTPUT"
- name: 📦 Determine what should be published
uses: actions/github-script@v7
id: items-to-publish
env:
CHANGED_ITEMS: "${{ steps.release-please.outputs.paths_released }}"
with:
# Release please outputs a string representation of an array under the key paths_released
# This script parses the output, and filters each of the changed items (provided as paths to the root of the package)
# to remove any values not present in the PUBLISHABLE_ITEMS array. This filtered array is then stringified and exported as items-to-publish.outputs.result
# this can be picked up by subsequent jobs and used in a matrix to loop over the PUBLISHABLE_ITEMS within the release
script: |
const changedItems = JSON.parse(process.env.CHANGED_ITEMS || '[]');
console.log("changed items", changedItems);
const eligibleItems = JSON.parse(process.env.PUBLISHABLE_ITEMS || '[]');
console.log("eligible items", eligibleItems);
const itemsToPublish = changedItems.filter(i => eligibleItems.includes(i));
console.log("items to publish", itemsToPublish);
return itemsToPublish;
outputs:
items_to_publish: ${{ steps.items-to-publish.outputs.result }}
releases: ${{ toJson(steps.release-please.outputs) }}
# prepare-release:
# name: Prepare
# runs-on: ubuntu-latest
# needs: release
# if: ${{ needs.release.outputs.items_to_publish != '' && toJson(fromJson(needs.release.outputs.items_to_publish)) != '[]' }}
# steps:
release-charts:
name: Release Charts
needs: release
runs-on: ubuntu-latest
if: ${{ needs.release.outputs.items_to_publish != '' && toJson(fromJson(needs.release.outputs.items_to_publish)) != '[]' }}
strategy:
fail-fast: false
matrix:
path: ${{ fromJSON(needs.release.outputs.items_to_publish) }}
env:
TAG: ${{ fromJson(needs.release.outputs.releases)[format('{0}--tag_name', matrix.path)] }}
VERSION: ${{ fromJson(needs.release.outputs.releases)[format('{0}--version', matrix.path)] }}
steps:
- name: 🐛 Debug
run: |
echo ${{ env.TAG }}
echo ${{ env.VERSION }}
echo ${{ matrix.path }}
- name: ✨ Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🔧 Configure Git
run: |
echo ${{ needs.release.outputs.items_to_publish }}
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: 🔧 Install Chart Releaser
run: |
version=v1.6.0
mkdir .tmp
install_dir=.tmp
echo "Installing chart-releaser on $install_dir..."
curl -sSLo cr.tar.gz "https://github.com/helm/chart-releaser/releases/download/$version/chart-releaser_${version#v}_linux_amd64.tar.gz"
tar -xzf cr.tar.gz -C "$install_dir"
rm -f cr.tar.gz
- name: 📦 Package chart
run: |
.tmp/cr package ${{ matrix.path }}
ls -la .cr-release-packages/
- name: 📢 Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: .cr-release-packages/*.tgz
file_glob: true
overwrite: true
tag: ${{ env.TAG }}
- name: 📁 Upadate index
run: |
owner=$(cut -d '/' -f 1 <<< "$GITHUB_REPOSITORY")
repo=$(cut -d '/' -f 2 <<< "$GITHUB_REPOSITORY")
args=(-o "$owner" -r "$repo" --push -t "${{ secrets.CR_TOKEN }}" --index-path .)
.tmp/cr index "${args[@]}"