Skip to content

Commit

Permalink
Add releaser and publisher workflows and rename builder (#8)
Browse files Browse the repository at this point in the history
* Add releaser workflow

* Rename builder workflow and simplify

* Add publisher workflow

* Rename secret

* Remove changelog file in favour of release notes

* Update releaser perms

* Set publisher perms

* Revert "Remove changelog file in favour of release notes"

This reverts commit a003ee3.
  • Loading branch information
lildude authored Apr 20, 2024
1 parent ba55d1b commit 37a1098
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 99 deletions.
99 changes: 0 additions & 99 deletions .github/workflows/builder.yaml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/publisher.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "Publish"

on:
release:
types: [published]

jobs:
publish:
name: Publish
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
arch: ["amd64", "armv7", "aarch64"]

steps:
- name: Checkout the repository
uses: actions/[email protected]

- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish
uses: home-assistant/builder@master
with:
args: |
--${{ matrix.arch }} \
--target /data/ \
--addon
66 changes: 66 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
on:
workflow_dispatch:
inputs:
semverIncrement:
description: Increment major/minor/patch using values of m/i/p
required: true
default: i

name: Releaser

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: 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: 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 }}
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
44 changes: 44 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test

on:
push:
branches:
- main
paths:
- build.yaml
- config.yaml
- build.json
- config.json
- Dockerfile
- rootfs/**
pull_request:
branches:
- main
paths:
- build.yaml
- config.yaml
- build.json
- config.json
- Dockerfile
- rootfs/**

jobs:
build:
runs-on: ubuntu-latest
name: Build add-on
strategy:
matrix:
arch: ["amd64", "armv7", "aarch64"]

steps:
- name: Check out repository
uses: actions/[email protected]

- name: Build add-on
uses: home-assistant/builder@master
with:
args: |
--test \
--${{ matrix.arch }} \
--target /data/ \
--addon

0 comments on commit 37a1098

Please sign in to comment.