-
Notifications
You must be signed in to change notification settings - Fork 29
71 lines (63 loc) · 2.13 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
name: Create Release
on:
push:
tags:
- "v*"
jobs:
branch_exists:
runs-on: ubuntu-20.04
outputs:
branch_exists: ${{ steps.check_branch.outputs.branch_exists }}
steps:
- uses: actions/checkout@v2
- name: Check if release already exists
id: check_branch
env:
REF: ${{ github.ref }}
run: |
echo "branch_exists=$(git ls-remote --heads origin refs/heads/release/${REF:10} | wc -l)" >> $GITHUB_OUTPUT
release:
runs-on: ubuntu-20.04
needs: branch_exists
if: ${{ needs.branch_exists.outputs.branch_exists == 0 }}
steps:
- uses: actions/checkout@v2
- name: Bump version if needed
continue-on-error: true
env:
REF: ${{ github.ref }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git checkout -b ${REF:10}-update
git tag -d ${REF:10}
git push -d origin ${REF:10}
sed -i "s/version = \".*\"/version = \"${REF:11}\"/" pyproject.toml
git add pyproject.toml
git commit -m "bump version for release"
git tag -a ${REF:10} -m "${REF:10}"
git push -u origin HEAD:main ${REF:10}
- name: Create release branch and bump version
env:
REF: ${{ github.ref }}
run: |
BRANCH=release/${REF:10}
git checkout -b $BRANCH
git push -u origin $BRANCH
- name: Extract Changelog
id: extract_changelog
env:
REF: ${{ github.ref }}
run: |
sed -n "/^## ${REF:10}/,/^## /{/^## /b;p}" docs/changelog.md | sed -r '1d;$d' > ./RELEASE_CHANGELOG
echo ::set-output name=version_name::`sed -nr "s/^## (${REF:10}.*)$/\1/p" docs/changelog.md`
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ steps.extract_changelog.outputs.version_name }}
body_path: ./RELEASE_CHANGELOG
draft: true