-
Notifications
You must be signed in to change notification settings - Fork 1
63 lines (51 loc) · 1.66 KB
/
publish.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
---
name: release
concurrency:
group: release
cancel-in-progress: true
on: release
permissions:
contents: read
jobs:
detect-versions:
runs-on: ubuntu-latest
outputs:
branch-exists: ${{ steps.branch-exists.outputs.exists }}
version: v${{ steps.version.outputs.value }}
steps:
- uses: actions/checkout@v4
# Detect version from pyproject.toml
- uses: SebRollen/[email protected]
id: version
with:
file: './pyproject.toml'
field: project.version
- uses: GuillaumeFalourd/branch-exists@v1
id: branch-exists
with:
branch: v${{ steps.version.outputs.value }}
- name: Fail on branch conflict
if: steps.branch-exists.outputs.exists == 'true'
shell: bash
run: |
echo "ERROR: A branch already exists called v${{ steps.version.outputs.value }}"
echo " Update package.json to refer to a new version."
exit 1
# The below code is commented out because it works, except for a Github auth issue.
# Ref: https://github.com/orgs/community/discussions/13836
# When the PR gets merged, cut a new version branch.
merge:
needs: detect-versions
if: needs.detect-versions.outputs.branch-exists == 'false'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create a new version branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
git checkout -b ${{ needs.detect-versions.outputs.version }}
git push -u origin ${{ needs.detect-versions.outputs.version }}