-
Notifications
You must be signed in to change notification settings - Fork 12
65 lines (57 loc) · 2.35 KB
/
prerelease_on_version_bump.yaml
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
name: Prerelease on Version Bump
on:
push:
branches:
- master
jobs:
pre-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all tags and branches
- name: Detect single custom component directory
id: detect_integration
run: |
DIR_COUNT=$(find custom_components/* -maxdepth 0 -type d | wc -l)
if [ "$DIR_COUNT" -ne "1" ]; then
echo "Error: There must be exactly one custom component directory." >&2
exit 1
fi
echo "DOMAIN=$(basename $(find custom_components/* -maxdepth 0 -type d))" >> $GITHUB_ENV
- name: Install JQ
run: sudo apt-get install jq
- name: Extract version from current commit
id: current_version
run: echo "CURRENT_VERSION=$(jq -r '.version' custom_components/$DOMAIN/manifest.json)" >> $GITHUB_ENV
- name: Extract version from previous commit
id: previous_version
run: echo "PREVIOUS_VERSION=$(git show HEAD~:custom_components/$DOMAIN/manifest.json | jq -r '.version')" >> $GITHUB_ENV
- name: Create Tag
if: ${{ env.CURRENT_VERSION != env.PREVIOUS_VERSION }}
uses: actions/github-script@v7
with:
script: |
const version = '${{ steps.current_version.outputs.version }}';
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/v${version}`,
sha: '${{ github.sha }}'
});
- name: Create Pre-release
if: ${{ env.CURRENT_VERSION != env.PREVIOUS_VERSION }}
uses: actions/github-script@v7
with:
script: |
const version = '${{ steps.current_version.outputs.version }}';
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `v${version}`,
name: `v${version}`,
body: "## :new: Нововведения\n\n<!-- ... -->\n\n## :bug: Исправления\n\n<!-- ... -->\n\n## :wrench: Изменения\n\n<!-- ... -->\n\n## :information_source: Примечания\n\n<!-- ... -->",
draft: false,
prerelease: true,
});