generated from plus3it/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 5
72 lines (66 loc) · 2.42 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
name: Create GitHub Release
on:
# Run as a reusable workflow
workflow_call:
inputs:
mockstacktest-enable:
description: Controls whether to run the mockstacktest job
default: true
required: false
type: boolean
mockstacktest-pytest-args:
description: Passes PYTEST_ARGS to mockstacktest
default: -v
required: false
type: string
secrets:
release-token:
description: Token with permissions to create GitHub Releases
required: true
jobs:
lint:
uses: ./.github/workflows/lint.yml
test:
uses: ./.github/workflows/test.yml
with:
mockstacktest-enable: ${{ inputs.mockstacktest-enable }}
mockstacktest-pytest-args: ${{ inputs.mockstacktest-pytest-args }}
release:
needs:
- lint
- test
# The test workflow is optional, and may be "skipped". The release should be
# created as long as the test does not fail. See also:
# <https://samanpavel.medium.com/github-actions-conditional-job-execution-e6aa363d2867>
if: |
always() &&
needs.lint.result == 'success' &&
(needs.test.result == 'success' || needs.test.result == 'skipped')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- run: git fetch --tags --force origin # WA: https://github.com/actions/checkout/issues/882
- name: Test release condition
id: release
run: |
set -eu -o pipefail
RELEASE=false
PRIOR_VERSION=$(git describe --abbrev=0 --tags || true)
RELEASE_VERSION=$(grep -E "current_version\s*=" .bumpversion.cfg | sed 's/^.*= //' )
if [[ "$PRIOR_VERSION" != "$RELEASE_VERSION" ]]; then RELEASE=true; fi
echo "condition=${RELEASE}"
echo "version=${RELEASE_VERSION}"
echo "condition=${RELEASE}" >> "$GITHUB_OUTPUT"
echo "version=${RELEASE_VERSION}" >> "$GITHUB_OUTPUT"
- name: Create release
if: steps.release.outputs.condition == 'true'
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048
with:
name: ${{ steps.release.outputs.version }}
tag_name: ${{ steps.release.outputs.version }}
generate_release_notes: true
target_commitish: ${{ github.sha }}
token: ${{ secrets.release-token }}