Skip to content

Commit f183a5e

Browse files
committed
OPS: Allow manual releases with release workflow
skipci
1 parent cc5fc13 commit f183a5e

File tree

1 file changed

+40
-13
lines changed

1 file changed

+40
-13
lines changed

.github/workflows/release.yml

+40-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# This workflow tests and releases a new version of the package, then publishes it to PyPi and the
2-
# octue/octue-sdk-python Docker Hub repository.
1+
# This workflow tests and releases a new version of the package before publishing it to PyPi.
32

43
name: Release
54

@@ -10,9 +9,20 @@ on:
109
branches:
1110
- main
1211

12+
workflow_dispatch:
13+
inputs:
14+
ref:
15+
description: "Branch or commit SHA to tag"
16+
type: string
17+
required: true
18+
tag:
19+
description: "Tag for release"
20+
type: string
21+
required: true
22+
1323
jobs:
1424
run-tests:
15-
if: "github.event.pull_request.merged == true"
25+
if: "${{ github.event_name == 'workflow_dispatch' || && github.event.pull_request.merged == true }}"
1626
runs-on: ${{ matrix.os }}
1727
env:
1828
USING_COVERAGE: "3.10"
@@ -23,7 +33,9 @@ jobs:
2333
id-token: write
2434
steps:
2535
- name: Checkout Repository
26-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
37+
with:
38+
ref: ${{ inputs.ref }}
2739

2840
- name: Setup Python
2941
uses: actions/setup-python@v5
@@ -36,10 +48,6 @@ jobs:
3648
- name: Check pyproject.toml file
3749
run: poetry check
3850

39-
- name: Get package version
40-
id: get-package-version
41-
run: echo "PACKAGE_VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT
42-
4351
- name: Install tox
4452
run: pip install tox
4553

@@ -65,19 +73,36 @@ jobs:
6573
fail_ci_if_error: false
6674
token: ${{ secrets.CODECOV_TOKEN }}
6775

68-
outputs:
69-
package_version: ${{ steps.get-package-version.outputs.PACKAGE_VERSION }}
70-
7176
release:
7277
runs-on: ubuntu-latest
7378
needs: run-tests
7479
steps:
80+
- name: Checkout Repository
81+
if: ${{ github.event_name != 'workflow_dispatch' }}
82+
uses: actions/checkout@v4
83+
with:
84+
ref: ${{ inputs.ref }}
85+
86+
- name: Install Poetry
87+
if: ${{ github.event_name != 'workflow_dispatch' }}
88+
uses: snok/[email protected]
89+
90+
- name: Check pyproject.toml file
91+
if: ${{ github.event_name != 'workflow_dispatch' }}
92+
run: poetry check
93+
94+
- name: Get package version
95+
id: get-package-version
96+
if: ${{ github.event_name != 'workflow_dispatch' }}
97+
run: echo "package_version=$(poetry version -s)" >> $GITHUB_OUTPUT
98+
7599
- name: Create Release
76100
uses: actions/create-release@v1
77101
env:
78102
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, no need to create your own.
79103
with:
80-
tag_name: ${{ needs.run-tests.outputs.package_version }}
104+
commitish: ${{ inputs.ref }}
105+
tag_name: ${{ inputs.tag || steps.get-package-version.outputs.package_version }}
81106
release_name: ${{ github.event.pull_request.title }}
82107
body: ${{ github.event.pull_request.body }}
83108
draft: false
@@ -92,7 +117,9 @@ jobs:
92117

93118
steps:
94119
- name: Checkout Repository
95-
uses: actions/checkout@v3
120+
uses: actions/checkout@v4
121+
with:
122+
ref: ${{ inputs.ref }}
96123

97124
- name: Install Poetry
98125
uses: snok/[email protected]

0 commit comments

Comments
 (0)