Releaser #40
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
workflow_dispatch: | |
inputs: | |
semverIncrement: | |
description: Increment major/minor/patch using values of m/i/p | |
required: true | |
default: i | |
name: Releaser | |
jobs: | |
release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.semver.outputs.semver }} | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
path: ghostfolio | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get latest release | |
run: | | |
echo "latest_release=$(curl --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --silent https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r .tag_name | sed s/v// )" >> $GITHUB_ENV | |
- name: Increment semver | |
id: semver | |
uses: matt-FFFFFF/[email protected] | |
with: | |
semver-input: ${{ env.latest_release }} | |
increment: ${{ github.event.inputs.semverIncrement }} | |
- name: Get Ghostfolio release notes | |
run: | | |
touch CHANGELOG.txt | |
last_release_date=$(gh release list --repo lildude/ha-addon-ghostfolio --limit=1 --json=publishedAt | jq -r '.[].publishedAt') | |
gh pr list --repo lildude/ha-addon-ghostfolio --state=merged --search="Update Ghostfolio in:title closed:>$last_release_date" --limit=1 --json=body --jq '.[].body' | sed -n "/<\/summary>/,/<\/details>/p" | sed '1d;$d' > changelog.tmp | |
if [ -s changelog.tmp ]; then | |
echo "## Ghostfolio Release Notes" > CHANGELOG.txt | |
cat changelog.tmp >> CHANGELOG.txt | |
echo -e "---\n\n## Add-on Release Notes\n\n" >> CHANGELOG.txt | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create tag | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
git tag -a v${{ steps.semver.outputs.semver }} -m 'Release automation' | |
git push --tags | |
working-directory: ${{ github.workspace }}/ghostfolio | |
- name: Create release | |
uses: softprops/[email protected] | |
with: | |
tag_name: v${{ steps.semver.outputs.semver }} | |
body_path: CHANGELOG.txt | |
generate_release_notes: true | |
draft: false | |
prerelease: false | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout addon repo | |
uses: actions/[email protected] | |
with: | |
path: repo | |
repository: lildude/ha-addons | |
token: ${{ secrets.HA_ADDONS_PAT }} | |
- name: Update addon repo | |
run: | | |
cp -vf ${{ github.workspace }}/ghostfolio/*.png ${{ github.workspace }}/repo/ghostfolio | |
cp -vf ${{ github.workspace }}/ghostfolio/*.md ${{ github.workspace }}/repo/ghostfolio | |
jq '.version="${{ steps.semver.outputs.semver }}"' < ${{ github.workspace }}/ghostfolio/config.json > ${{ github.workspace }}/repo/ghostfolio/config.json | |
echo "$(curl --silent --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r .body)" > ${{ github.workspace }}/repo/ghostfolio/CHANGELOG.md | |
- name: Add changes to addon repo | |
run: | | |
if [ "$(git status -s)" ]; then | |
git add . | |
git commit -m 'Update ha-addon-ghostfolio to v${{ steps.semver.outputs.semver }}' | |
git push | |
fi | |
working-directory: ${{ github.workspace }}/repo/ghostfolio | |
build: | |
name: Build addon | |
needs: release | |
permissions: | |
contents: read | |
packages: write | |
uses: ./.github/workflows/publisher.yaml | |
with: | |
version: ${{ needs.release.outputs.version }} |