Skip to content

chore(main): release pihole-2.26.2 (#320) #34

chore(main): release pihole-2.26.2 (#320)

chore(main): release pihole-2.26.2 (#320) #34

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 "[email protected]"
- 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[@]}"