-
-
Notifications
You must be signed in to change notification settings - Fork 28
149 lines (129 loc) · 4.79 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# 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 }}