ci: allow empty commits on manual releases #85
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
# Make new release based on conventional commits | |
name: Create release | |
# yamllint disable-line rule:truthy | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: 'Branch for release' | |
required: true | |
default: 'dev' | |
push: | |
branches: | |
- main | |
jobs: | |
prepare: | |
name: "Determinate branch based on event" | |
runs-on: ubuntu-latest | |
outputs: | |
branch: ${{steps.get_branch.output.branch}} | |
steps: | |
- name: get_branch | |
run: | | |
branch=`[ "${{ github.event_name }}" == "push" ] && echo "main" || echo "${{ github.event.inputs.branch }}"` | |
echo "::set-output name=branch::$(echo branch)" | |
changes: | |
name: "Create changelog and tag" | |
runs-on: ubuntu-latest | |
needs: prepare | |
outputs: | |
skipped: ${{ steps.changelog.outputs.skipped }} | |
clean_changelog: ${{ steps.changelog.outputs.clean_changelog }} | |
tag: ${{ steps.changelog.outputs.tag }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
id: checkout | |
- name: "Clean dev tags" | |
run: git tag -l --no-merged main | xargs git tag -d | |
- name: Conventional Changelog Action | |
id: changelog | |
uses: TriPSs/conventional-changelog-action@v3 | |
with: | |
github-token: ${{ secrets.github_token }} | |
output-file: "false" | |
skip-version-file: "true" | |
skip-commit: "true" | |
version_blueprint: | |
name: "Update version and blueprint" | |
needs: changes | |
if: ${{ needs.changes.outputs.skipped == 'false' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Check out repository" | |
uses: actions/checkout@v2 | |
- name: setup python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: "Prepare" | |
run: | | |
echo "NEW_VERSION=${{ needs.changes.outputs.tag }}" | sed -e 's/=v/=/' >> $GITHUB_ENV | |
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default | |
git config user.name "GitHub Actions Bot" | |
git config user.email "github-actions@no_spam.please" | |
- name: Update version file | |
id: update | |
run: sed -e "s/%%%VERSION%%%/${{ env.NEW_VERSION }}/" ./custom_components/sleep_as_android/manifest.json.tpl >custom_components/sleep_as_android/manifest.json | |
- name: Commit version | |
id: commit_version | |
run: | | |
git commit -m "chore(release): ${{ env.NEW_VERSION }}" custom_components/sleep_as_android/manifest.json | |
- name: Update blueprint | |
id: update_blueprint | |
run: | | |
pip install ruamel.yaml wheel | |
pip install homeassistant | |
python blueprint/blueprint_generator.py || true | |
- name: Commit bluepint | |
id: commit_blueprint | |
# We may skip this if blueprint was not updated | |
run: | | |
git commit -m "chore(blueprint): update blueprints for ${{ env.NEW_VERSION }}" blueprint/*.yaml || true | |
- name: Update | |
id: update_tag | |
run: | | |
git push origin main && \ | |
git tag -f -a -m "v${{ env.NEW_VERSION }}" v${{ env.NEW_VERSION }} && git push -f --tags || true | |
release: | |
name: "Create release" | |
needs: [changes, version_blueprint] | |
if: ${{ needs.changes.outputs.skipped == 'false' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Check out repository" | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ needs.changes.outputs.tag }} | |
- name: Get footer | |
id: footer | |
uses: juliangruber/read-file-action@v1 | |
with: | |
path: ./docs/feedback.md | |
- name: "Set package name" | |
working-directory: ./custom_components | |
run: | | |
echo "package=$(ls -F | grep \/$ | sed -n "s/\///g;1p")" >> $GITHUB_ENV | |
- name: "Set variables" | |
working-directory: ./custom_components | |
run: | | |
echo "archive=${{ env.package }}.zip" >> $GITHUB_ENV | |
echo "basedir=$(pwd)/${{ env.package }}" >> $GITHUB_ENV | |
env | |
- name: "Zip component dir" | |
working-directory: ./custom_components/${{ env.package }} | |
run: | | |
rm -f manifest.json.tpl | |
zip ${{ env.archive }} -r ./ | |
- name: Create Release | |
id: release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ needs.changes.outputs.tag }} | |
name: ${{ needs.changes.outputs.tag }} | |
draft: true | |
files: ${{ env.basedir }}/${{ env.archive }} | |
body: | | |
[](https://github.com/${{ github.repository }}/releases/tag/${{ needs.changes.outputs.tag }}) | |
${{ needs.changes.outputs.clean_changelog }} | |
${{ steps.footer.outputs.content }} |