Skip to content

Commit

Permalink
ci: add manual release flow
Browse files Browse the repository at this point in the history
  • Loading branch information
IATkachenko authored Jan 27, 2025
1 parent c59dd3c commit 042ce00
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/manual_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Make new release based on conventional commits
name: Manual create release

# yamllint disable-line rule:truthy
on:
workflow_dispatch:
inputs:
tag:
description: 'tag to release'
required: true

jobs:
version:
name: "Update version"
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: "Setup environment"
run: |
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%%%/${{ github.event.inputs.tag }}/" ./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): ${{ github.event.inputs.tag }}" custom_components/sleep_as_android/manifest.json || true
- name: Update
id: update_tag
run: |
git push origin main && \
git tag -f -a -m "v${{ github.event.inputs.tag }}" v${{ github.event.inputs.tag }} && git push -f --tags || true
release:
name: "Create release"
needs: [version]
runs-on: ubuntu-latest

steps:
- name: "Check out repository"
uses: actions/checkout@v2
with:
ref: v${{ github.event.inputs.tag }}

- 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: v${{ github.event.inputs.tag }}
name: v${{ github.event.inputs.tag }}
draft: true
files: ${{ env.basedir }}/${{ env.archive }}
body: |
[![GitHub release (by tag)](https://img.shields.io/github/downloads/${{ github.repository }}/v${{ github.event.inputs.tag }}/total?style=plastic)](https://github.com/${{ github.repository }}/releases/tag/v${{ github.event.inputs.tag }})
"Put changelog here"
${{ steps.footer.outputs.content }}

0 comments on commit 042ce00

Please sign in to comment.