Skip to content

Commit 976e3ea

Browse files
committed
refactoring workflows
1 parent 9f94f75 commit 976e3ea

File tree

3 files changed

+110
-76
lines changed

3 files changed

+110
-76
lines changed

.github/workflows/publish.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Publish
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
candidate:
6+
description: 'Release candidate.'
7+
required: true
8+
type: boolean
9+
default: true
10+
test_pypi:
11+
description: 'Test PyPI.'
12+
type: boolean
13+
default: false
14+
15+
workflow_call:
16+
inputs:
17+
candidate:
18+
description: 'Release candidate.'
19+
required: true
20+
type: boolean
21+
default: true
22+
test_pypi:
23+
description: 'Test PyPI.'
24+
type: boolean
25+
default: false
26+
jobs:
27+
release:
28+
runs-on: ubuntu-latest
29+
permissions:
30+
id-token: write
31+
steps:
32+
- uses: actions/checkout@v4
33+
with:
34+
ref: ${{ inputs.candidate && 'main' || 'stable' }}
35+
36+
- name: Set up latest Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version-file: 'pyproject.toml'
40+
41+
- name: Install dependencies
42+
run: |
43+
python -m pip install --upgrade pip
44+
python -m pip install .[dev]
45+
46+
- name: Create wheel
47+
run: |
48+
make dist
49+
50+
- name: Publish a Python distribution to PyPI
51+
uses: pypa/gh-action-pypi-publish@release/v1
52+
with:
53+
repository-url: ${{ inputs.test_pypi && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
54+
55+
- name: Bump version to next candidate
56+
if: ${{ inputs.candidate && !inputs.test_pypi }}
57+
run: |
58+
git config user.name "github-actions[bot]"
59+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
60+
bump-my-version bump candidate --no-tag --no-commit
61+
62+
- name: Create pull request
63+
if: ${{ inputs.candidate && !inputs.test_pypi }}
64+
id: cpr
65+
uses: peter-evans/create-pull-request@v4
66+
with:
67+
token: ${{ secrets.GH_ACCESS_TOKEN }}
68+
commit-message: bumpversion-candidate
69+
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
70+
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
71+
signoff: false
72+
delete-branch: true
73+
title: Automated Bump Version Candidate
74+
body: "This is an auto-generated PR that bumps the version to the next candidate."
75+
branch: bumpversion-candidate-update
76+
branch-suffix: short-commit-hash
77+
add-paths: |
78+
rdt/__init__.py
79+
pyproject.toml
80+
draft: false
81+
base: main
82+
83+
- name: Enable Pull Request Automerge
84+
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
85+
run: gh pr merge "${{ steps.cpr.outputs.pull-request-number }}" --squash --admin
86+
env:
87+
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}

.github/workflows/publish_download_tracker.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ on:
44
types: [published]
55
pull_request:
66
workflow_dispatch:
7+
inputs:
8+
source_branch:
9+
description: 'The branch to create the download tracker package from.'
10+
required: true
11+
type: string
12+
default: 'stable'
13+
workflow_call:
14+
inputs:
15+
source_branch:
16+
description: 'The branch to create the download tracker package from.'
17+
required: true
18+
type: string
19+
default: 'stable'
720

821
jobs:
922
publish-download-tracker:
@@ -13,7 +26,7 @@ jobs:
1326
steps:
1427
- uses: actions/checkout@v4
1528
# with:
16-
# ref: 'stable'
29+
# ref: ${{ inputs.source_branch }}
1730
- name: Set up latest Python
1831
uses: actions/setup-python@v5
1932
with:

.github/workflows/release.yml

Lines changed: 9 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,14 @@ name: Release
22
on:
33
release:
44
types: [published]
5-
branches:
6-
- main
7-
- stable
8-
9-
workflow_dispatch:
10-
inputs:
11-
candidate:
12-
description: 'Release candidate.'
13-
required: true
14-
type: boolean
15-
default: true
16-
test_pypi:
17-
description: 'Test PyPI.'
18-
type: boolean
19-
default: false
5+
206
jobs:
217
release:
22-
runs-on: ubuntu-latest
23-
permissions:
24-
id-token: write
25-
steps:
26-
- uses: actions/checkout@v4
27-
with:
28-
ref: ${{ inputs.candidate && 'main' || 'stable' }}
29-
30-
- name: Set up latest Python
31-
uses: actions/setup-python@v5
32-
with:
33-
python-version-file: 'pyproject.toml'
34-
35-
- name: Install dependencies
36-
run: |
37-
python -m pip install --upgrade pip
38-
python -m pip install .[dev]
39-
40-
- name: Create wheel
41-
run: |
42-
make dist
43-
44-
- name: Publish a Python distribution to PyPI
45-
uses: pypa/gh-action-pypi-publish@release/v1
46-
with:
47-
repository-url: ${{ inputs.test_pypi && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
48-
49-
- name: Bump version to next candidate
50-
if: ${{ inputs.candidate && !inputs.test_pypi }}
51-
run: |
52-
git config user.name "github-actions[bot]"
53-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
54-
bump-my-version bump candidate --no-tag --no-commit
55-
56-
- name: Create pull request
57-
if: ${{ inputs.candidate && !inputs.test_pypi }}
58-
id: cpr
59-
uses: peter-evans/create-pull-request@v4
60-
with:
61-
token: ${{ secrets.GH_ACCESS_TOKEN }}
62-
commit-message: bumpversion-candidate
63-
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
64-
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
65-
signoff: false
66-
delete-branch: true
67-
title: Automated Bump Version Candidate
68-
body: "This is an auto-generated PR that bumps the version to the next candidate."
69-
branch: bumpversion-candidate-update
70-
branch-suffix: short-commit-hash
71-
add-paths: |
72-
rdt/__init__.py
73-
pyproject.toml
74-
draft: false
75-
base: main
76-
77-
- name: Enable Pull Request Automerge
78-
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
79-
run: gh pr merge "${{ steps.cpr.outputs.pull-request-number }}" --squash --admin
80-
env:
81-
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
8+
uses: ./.github/workflows/publish.yml
9+
with:
10+
candidate: false
11+
test_pypi: false
12+
release-download-tracker:
13+
uses: ./.github/workflows/publish_download_tracker.yml
14+
with:
15+
source_branch: 'stable'

0 commit comments

Comments
 (0)