Skip to content

Commit e65b0c6

Browse files
authored
Merge pull request #105 from callowayproject/workflows
Test Workflows
2 parents f2c343b + 67ab83d commit e65b0c6

File tree

6 files changed

+136
-102
lines changed

6 files changed

+136
-102
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Package and upload artifacts
2+
description: Package a Python project and upload the artifacts and release notes
3+
inputs:
4+
tag-name:
5+
description: 'The name of the tag for the GitHub release'
6+
required: true
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- name: Parse changelog for release notes
11+
shell: bash
12+
run: |
13+
function extract_version_content() {
14+
changelog=$1
15+
target_version=$2
16+
17+
awk -v target="$target_version" '
18+
/^## / {
19+
if (found) exit;
20+
version=$2;
21+
if (version == target) found=1;
22+
next;
23+
}
24+
found { print; }
25+
' <<< "$changelog"
26+
}
27+
28+
changelog=$(cat "CHANGELOG.md")
29+
target_version=${{ inputs.tag-name }}
30+
echo "TAG_NAME=$target_version" >> $GITHUB_ENV
31+
content=$(extract_version_content "$changelog" "$target_version")
32+
33+
if [ -n "$content" ]; then
34+
echo "::notice::Found release notes for ${target_version}"
35+
echo "$content" >> release-notes.md
36+
else
37+
echo "::warning::Did not find release notes for ${target_version}"
38+
touch release-notes.md
39+
fi
40+
41+
- name: Upload release notes
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: release-notes
45+
path: release-notes.md
46+
47+
- name: Package and upload artifacts
48+
if: ${{ env.PACKAGE == 'true' }}
49+
uses: hynek/build-and-inspect-python-package@v2

.github/actions/release/action.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release
2+
description: Create a GitHub release and upload the package to PyPI
3+
inputs:
4+
pypi-api-token:
5+
description: 'PyPI API token'
6+
required: true
7+
tag-name:
8+
description: 'The name of the tag for the GitHub release'
9+
required: true
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Download packages built by build-and-inspect-python-package
15+
uses: actions/download-artifact@v4
16+
with:
17+
path: artifacts
18+
19+
- name: Download packages built by build-and-inspect-python-package
20+
uses: actions/download-artifact@v4
21+
with:
22+
name: Packages
23+
path: dist
24+
25+
- name: Download release notes
26+
uses: actions/download-artifact@v4
27+
with:
28+
name: release-notes
29+
30+
- name: Create a GitHub release
31+
uses: softprops/action-gh-release@v1
32+
with:
33+
files: dist/*
34+
tag_name: "${{ env.TAG_NAME }}"
35+
body_path: release-notes.md
36+
37+
- name: Upload package to PyPI
38+
uses: pypa/gh-action-pypi-publish@release/v1
39+
with:
40+
password: ${{ inputs.pypi-api-token }}

.github/workflows/release.yaml

-83
This file was deleted.

.github/workflows/ci.yaml .github/workflows/test.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: CI
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize]
6-
branches: [master]
4+
workflow_call:
5+
# pull_request:
6+
# types: [opened, synchronize]
7+
# branches: [master]
78

89
defaults:
910
run:

.github/workflows/bumpversion-pr.yaml .github/workflows/version-preview.yaml

+11-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches: [master]
66

77
jobs:
8-
bumpversion:
8+
preview-version-hint:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
@@ -32,14 +32,20 @@ jobs:
3232
echo "RELEASE_KIND=$RELEASE_KIND" >> $GITHUB_ENV
3333
echo "release-kind=$RELEASE_KIND" >> $GITHUB_OUTPUT
3434
35+
- name: Get Pull Request Number
36+
id: pr
37+
run: |
38+
PR_NUMBER=$(gh pr view --json number -q .number || echo "${{ github.event.number }}")
39+
echo "pull_request_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
40+
echo "::notice::PR_NUMBER is ${PR_NUMBER}"
41+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.PAT }}
44+
3545
- name: Bump version dry run
3646
if: ${{ env.RELEASE_KIND != 'no-release' }}
3747
shell: bash
3848
run: |
39-
PR_NUMBER=$(gh pr view --json number -q .number || echo "")
40-
REVISION=$(git describe --tags --long | awk -F- '{print $2}')
41-
export PR_NUMBER REVISION
42-
4349
# This will display a full log of what would happen if we were to bump the version.
4450
bump-my-version bump --dry-run --verbose "$RELEASE_KIND"
4551

.github/workflows/bumpversion.yaml .github/workflows/version.yaml

+32-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
name: Bump the version on merge
22
on:
33
pull_request:
4-
types: [closed]
4+
# types: [closed]
55
branches: [master]
66

77
jobs:
8-
version-hint:
8+
version:
9+
permissions:
10+
id-token: write
11+
pull-requests: read
912
runs-on: ubuntu-latest
1013
steps:
1114
- uses: actions/checkout@v4
@@ -32,25 +35,43 @@ jobs:
3235
echo "release-kind=$RELEASE_KIND" >> $GITHUB_OUTPUT
3336
echo "PACKAGE=false" >> $GITHUB_ENV
3437
38+
- name: Get Pull Request Number
39+
id: pr
40+
run: |
41+
PR_NUMBER=$(gh pr view --json number -q .number || echo "${{ github.event.number }}")
42+
echo "pull_request_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
43+
echo "::notice::PR_NUMBER is ${PR_NUMBER}"
44+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.PAT }}
47+
3548
- name: Bump version
3649
if: ${{ env.RELEASE_KIND != 'no-release' }}
3750
shell: bash
3851
run: |
39-
PR_NUMBER=$(gh pr view --json number -q .number || echo "")
40-
REVISION=$(git describe --tags --long | awk -F- '{print $2}')
41-
export PR_NUMBER REVISION
4252
case "$RELEASE_KIND" in
4353
major|minor|patch)
4454
bump-my-version bump --allow-dirty --verbose "$RELEASE_KIND"
45-
git push
46-
git push --tags
55+
echo "TAG_NAME=$(bump-my-version show current_version)" >> $GITHUB_ENV
56+
# git push
57+
# git push --tags
4758
echo "PACKAGE=true" >> $GITHUB_ENV
4859
;;
4960
dev)
50-
echo "Intentionally not bumping version for dev release"
61+
echo "Temporary dev release for testing"
62+
bump-my-version bump --allow-dirty --verbose --no-commit "$RELEASE_KIND"
63+
echo "TAG_NAME=$(bump-my-version show current_version)" >> $GITHUB_ENV
64+
echo "PACKAGE=true" >> $GITHUB_ENV
65+
# echo "Intentionally not bumping version for dev release"
5166
;;
5267
esac
5368
54-
- name: Package
55-
if: ${{ env.PACKAGE == 'true' }}
56-
uses: hynek/build-and-inspect-python-package@v1
69+
# - name: Package and upload artifacts
70+
# if: ${{ env.PACKAGE == 'true' }}
71+
# uses: ./.github/actions/package-and-upload-artifacts
72+
# with:
73+
# tag-name: ${{ env.TAG_NAME }}
74+
75+
# - name: Create a GitHub release
76+
# if: ${{ env.PACKAGE == 'true' }}
77+
# uses: ./.github/actions/release

0 commit comments

Comments
 (0)