-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (88 loc) · 3.16 KB
/
Copy pathcreate-release.yaml
File metadata and controls
100 lines (88 loc) · 3.16 KB
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
name: Create release
on:
workflow_dispatch:
inputs:
base-branch:
description: 'Base branch to create the release from.'
required: true
default: 'main'
release-type:
description: 'Type of release to create (major, minor, or patch).'
required: true
type: choice
options:
- major
- minor
- patch
jobs:
create-pull-request:
name: Create pull request
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Get GitHub token
uses: actions/create-github-app-token@v2
id: github-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ steps.github-token.outputs.token }}
- name: Set up environment
uses: ./.github/actions/setup-environment
with:
python-version: 3.14
- name: Bump version
id: bump-version
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
run: |
echo "version=$(poetry version "$RELEASE_TYPE" --short)" >> "$GITHUB_OUTPUT"
git add pyproject.toml
- name: Create release branch
env:
VERSION: ${{ steps.bump-version.outputs.version }}
run: |
git config user.name "hass-free-sleep[bot]"
git config user.email "245959007+hass-free-sleep[bot]@users.noreply.github.com"
git checkout -b "release/v$VERSION"
MANIFEST_FILE="./custom_components/free_sleep/manifest.json"
jq --arg version "$VERSION" '.version = $version' "$MANIFEST_FILE" > tmp.json && mv tmp.json "$MANIFEST_FILE"
git add "$MANIFEST_FILE"
git commit -m "chore: Bump version to v$VERSION"
git push origin "release/v$VERSION"
- name: Get release notes
id: release-notes
env:
GH_TOKEN: ${{ steps.github-token.outputs.token }}
BASE_BRANCH: ${{ github.event.inputs.base-branch }}
VERSION: ${{ steps.bump-version.outputs.version }}
REPOSITORY: ${{ github.repository }}
run: |
RELEASE_NOTES=$(gh api --method POST "/repos/$REPOSITORY/releases/generate-notes" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f "tag_name=v$VERSION" \
-f "target_commitish=$BASE_BRANCH" \
-q .body)
{
echo "release-notes<<EOF"
echo "$RELEASE_NOTES"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create pull request
env:
BASE_BRANCH: ${{ github.event.inputs.base-branch }}
VERSION: ${{ steps.bump-version.outputs.version }}
GH_TOKEN: ${{ steps.github-token.outputs.token }}
RELEASE_NOTES: ${{ steps.release-notes.outputs.release-notes }}
run: |
gh pr create \
--title "chore: Release $VERSION" \
--body "$RELEASE_NOTES" \
--head "release/v$VERSION" \
--base "$BASE_BRANCH"