-
Notifications
You must be signed in to change notification settings - Fork 4
89 lines (76 loc) · 2.82 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
---
name: Release
on: # yamllint disable-line rule:truthy
push:
branches:
- main # forward-compatibility with new GitHub default branch naming
- master # backward-compatibility with old GitHub default branch naming
jobs:
# Shared tag & version number info ----------------------
get-tag-xor-dev-version:
name: Get tags and version numbers
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.detect-new-version-tag.outputs.tag }}
dev-version: ${{ steps.bump-dev-version.outputs.version }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v4.6.1
with:
python-version: "3.11"
- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Check if there is a parent commit
id: check-parent-commit
run: |
echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_OUTPUT
- name: Detect and tag new version
id: detect-new-version-tag
if: "steps.check-parent-commit.outputs.sha"
run: |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
git checkout HEAD~
PARENT_COMMIT_VER=$(make get-project-version-number)
git checkout "${BRANCH_NAME}"
CURRENT_COMMIT_VER=$(make get-project-version-number)
if [[ "${PARENT_COMMIT_VER}" != "${CURRENT_COMMIT_VER}" ]]; then
echo "tag=${CURRENT_COMMIT_VER}" >> $GITHUB_OUTPUT
fi
- name: Bump version for developmental release
id: bump-dev-version
if: "! steps.detect-new-version-tag.outputs.tag"
run: |
poetry version patch &&
VERSION=$(make get-project-version-number) &&
DEV_VERSION="${VERSION}.dev.$(date +%s)" &&
poetry version "${DEV_VERSION}" &&
echo "version=${DEV_VERSION}" >> $GITHUB_OUTPUT
# Release notes publication ----------------------
publish-release-notes:
name: Publish release notes
runs-on: ubuntu-latest
needs: get-tag-xor-dev-version
permissions:
pull-requests: write
contents: write
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Publish the release notes
uses: release-drafter/release-drafter@v5.23.0
with:
publish: ${{ needs.get-tag-xor-dev-version.outputs.tag != '' }}
# Annotated tag to associate with the current commit
tag: ${{ needs.get-tag-xor-dev-version.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}