Skip to content

Commit ec75c6c

Browse files
authored
fix: use external invoking for sub-actions (#13)
2 parents ccfda71 + 5de612b commit ec75c6c

File tree

9 files changed

+529
-16
lines changed

9 files changed

+529
-16
lines changed

.github/actions/version-bumping/maven/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ runs:
5858

5959
- name: Bump up project version
6060
id: bump
61-
uses: ./.github/actions/core
61+
uses: sap/pull-request-semver-bumper/.github/actions/core@main
6262
with:
6363
build-type: "maven"
6464
pom-file: ${{ inputs.pom-file }}

.github/actions/version-bumping/npm/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ runs:
6161

6262
- name: Bump up npm pr version
6363
id: bump
64-
uses: ./.github/actions/core
64+
uses: sap/pull-request-semver-bumper/.github/actions/core@main
6565
with:
6666
build-type: "npm"
6767
package-json-file: ${{ inputs.package-json-file }}

.github/actions/version-bumping/python/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ runs:
6060
6161
- name: Bump up project version
6262
id: bump
63-
uses: ./.github/actions/core
63+
uses: sap/pull-request-semver-bumper/.github/actions/core@main
6464
with:
6565
build-type: "python"
6666
pyproject-file: ${{ inputs.pyproject-file }}

.github/actions/version-bumping/version-file/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ runs:
5151

5252
- name: Bump up version file
5353
id: bump
54-
uses: ./.github/actions/core
54+
uses: sap/pull-request-semver-bumper/.github/actions/core@main
5555
with:
5656
build-type: "version-file"
5757
version-file: ${{ inputs.version-file }}

.github/workflows/build-and-test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ jobs:
7373
pull-requests: read
7474
steps:
7575
- uses: actions/checkout@v4
76+
- name: Patch composite actions for E2E
77+
run: |
78+
sed -i -E 's|sap/pull-request-semver-bumper/.github/actions/core@[^[:space:]"]+|./.github/actions/core|g' .github/actions/version-bumping/*/action.yml
79+
sed -i -E 's|sap/pull-request-semver-bumper/.github/actions/version-bumping/python@[^[:space:]"]+|./.github/actions/version-bumping/python|g' action.yml
7680
- name: Test Python Action (Dry Run)
7781
id: version_bump
7882
uses: ./
@@ -100,6 +104,10 @@ jobs:
100104
pull-requests: read
101105
steps:
102106
- uses: actions/checkout@v4
107+
- name: Patch composite actions for E2E
108+
run: |
109+
sed -i -E 's|sap/pull-request-semver-bumper/.github/actions/core@[^[:space:]"]+|./.github/actions/core|g' .github/actions/version-bumping/*/action.yml
110+
sed -i -E 's|sap/pull-request-semver-bumper/.github/actions/version-bumping/npm@[^[:space:]"]+|./.github/actions/version-bumping/npm|g' action.yml
103111
- name: Test NPM Action (Dry Run)
104112
id: version_bump
105113
uses: ./
@@ -127,6 +135,10 @@ jobs:
127135
pull-requests: read
128136
steps:
129137
- uses: actions/checkout@v4
138+
- name: Patch composite actions for E2E
139+
run: |
140+
sed -i -E 's|sap/pull-request-semver-bumper/.github/actions/core@[^[:space:]"]+|./.github/actions/core|g' .github/actions/version-bumping/*/action.yml
141+
sed -i -E 's|sap/pull-request-semver-bumper/.github/actions/version-bumping/maven@[^[:space:]"]+|./.github/actions/version-bumping/maven|g' action.yml
130142
- name: Test Maven Action (Dry Run)
131143
id: version_bump
132144
uses: ./
@@ -156,6 +168,10 @@ jobs:
156168
pull-requests: read
157169
steps:
158170
- uses: actions/checkout@v4
171+
- name: Patch composite actions for E2E
172+
run: |
173+
sed -i -E 's|sap/pull-request-semver-bumper/.github/actions/core@[^[:space:]"]+|./.github/actions/core|g' .github/actions/version-bumping/*/action.yml
174+
sed -i -E 's|sap/pull-request-semver-bumper/.github/actions/version-bumping/version-file@[^[:space:]"]+|./.github/actions/version-bumping/version-file|g' action.yml
159175
- name: Test Version File Action (Dry Run)
160176
id: version_bump
161177
uses: ./

.github/workflows/release.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to release (e.g., 1.0.0)"
8+
required: true
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Validate Version
19+
run: |
20+
if [[ ! "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
21+
echo "::error::Version must be in format X.Y.Z (e.g., 1.0.0)"
22+
exit 1
23+
fi
24+
echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV
25+
echo "MAJOR_VERSION=$(echo ${{ inputs.version }} | cut -d. -f1)" >> $GITHUB_ENV
26+
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Generate Changelog
33+
id: changelog
34+
uses: mikepenz/release-changelog-builder-action@v5
35+
with:
36+
# Using default configuration since configuration.json does not exist
37+
mode: "COMMIT"
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Create Changelog PR
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: |
45+
git config user.name "github-actions[bot]"
46+
git config user.email "github-actions[bot]@users.noreply.github.com"
47+
48+
BRANCH_NAME="chore/changelog-v$VERSION"
49+
git checkout -b "$BRANCH_NAME"
50+
51+
# Append changelog to CHANGELOG.md (create if not exists)
52+
touch CHANGELOG.md
53+
echo -e "\n## [$VERSION] - $(date +%Y-%m-%d)\n" >> CHANGELOG.md.tmp
54+
echo "${{ steps.changelog.outputs.changelog }}" >> CHANGELOG.md.tmp
55+
cat CHANGELOG.md >> CHANGELOG.md.tmp
56+
mv CHANGELOG.md.tmp CHANGELOG.md
57+
58+
git add CHANGELOG.md
59+
git commit -m "chore: update changelog for v$VERSION"
60+
git push origin "$BRANCH_NAME"
61+
62+
gh pr create \
63+
--title "chore: update changelog for v$VERSION" \
64+
--body "Automated changelog update for release v$VERSION" \
65+
--base main \
66+
--head "$BRANCH_NAME"
67+
68+
- name: Create Release Branch
69+
run: |
70+
git checkout main
71+
git pull origin main
72+
git checkout -b "release/v$VERSION"
73+
74+
- name: Update References
75+
run: |
76+
# Replace @main with @v{major} in action.yml and sub-actions
77+
# We use a broad sed to catch occurrences in both action.yml and sub-action files
78+
find . -name "action.yml" -print0 | xargs -0 sed -i "s|@main|@v$MAJOR_VERSION|g"
79+
80+
# Verify if any changes were made
81+
git diff
82+
83+
- name: Commit and Push Release Branch
84+
run: |
85+
git add .
86+
# Only commit if there are changes
87+
if ! git diff --quiet --cached; then
88+
git commit -m "chore: prepare release v$VERSION"
89+
git push origin "release/v$VERSION"
90+
else
91+
echo "No changes to commit (references might already be correct or using relative paths)."
92+
# We still push the branch to tag it
93+
git push origin "release/v$VERSION"
94+
fi
95+
96+
- name: Tagging
97+
run: |
98+
# Tag specific version
99+
git tag "v$VERSION"
100+
git push origin "v$VERSION"
101+
102+
# Tag/Move major version
103+
# Force update the major tag to point to this new release
104+
git tag -f "v$MAJOR_VERSION"
105+
git push -f origin "v$MAJOR_VERSION"
106+
107+
- name: Create Release
108+
uses: softprops/action-gh-release@v2
109+
with:
110+
tag_name: "v${{ inputs.version }}"
111+
name: "v${{ inputs.version }}"
112+
body: ${{ steps.changelog.outputs.changelog }}
113+
prerelease: false
114+
env:
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
117+
- name: Cleanup
118+
if: always()
119+
run: |
120+
# Delete the release branch
121+
git push origin --delete "release/v$VERSION" || true

0 commit comments

Comments
 (0)