Skip to content

Commit bda4fcd

Browse files
committed
Introduce auto releases
1 parent e99f300 commit bda4fcd

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed
File renamed without changes.

.github/workflows/create-release-post.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,40 @@ jobs:
1515
- uses: actions/checkout@v6
1616
with:
1717
ref: ${{ github.event.pull_request.base.ref }}
18+
token: ${{ secrets.PAT }}
1819
- name: Tag and Bump Snapshot
20+
env:
21+
GH_TOKEN: ${{ secrets.PAT }}
1922
run: |
2023
# Set git user
21-
git config user.name "github-actions[bot]";
22-
git config user.email "actions@github.com"
24+
git config user.name "Rollczi";
25+
git config user.email "[email protected].github.com"
2326
24-
# Create Release tag
25-
RELEASE_VERSION=$(jq -r '.versionRelease' .github/version.json)
26-
git tag "v$RELEASE_VERSION" && git push origin "v$RELEASE_VERSION"
27+
# Read Release tag
28+
RELEASE_VERSION=$(jq -r '.versionRelease' .github/release/version.json)
29+
30+
# Push tag
31+
if git ls-remote --tags origin | grep -q "refs/tags/v$VERSION"; then
32+
echo "⚠️ Skipped tag"
33+
else
34+
git tag "v$VERSION" && git push origin "v$VERSION"
35+
fi
2736
2837
# Create
29-
sed "s/{version}/$REL/g" .github/release-template.md > final_notes.md
30-
gh release create "RELEASE_VERSION" \
31-
--title "RELEASE_VERSION" \
38+
sed "s/{version}/$VERSION/g" .github/release/template.md > final_notes.md
39+
gh release create "v$VERSION" \
40+
--title "LiteCommands $VERSION" \
3241
--notes-file final_notes.md \
3342
--generate-notes
3443
3544
# Create Snapshot version
36-
IFS='.' read -ra V <<< "$RELEASE_VERSION"
45+
IFS='.' read -ra V <<< "$VERSION"
3746
NEXT_SNAPSHOT="${V[0]}.${V[1]}.$((V[2]+1))-SNAPSHOT"
3847
3948
# Update files litecommands-publish.gradle.kts (releaseVersion -> nextSnapshot)
40-
sed -i "s/$RELEASE_VERSION/$NEXT_SNAPSHOT/g" buildSrc/src/main/kotlin/litecommands-publish.gradle.kts
41-
jq ".versionSnapshot = \"$NEXT_SNAPSHOT\"" .github/version.json > t.json && mv t.json .github/version.json
49+
sed -i "s/$VERSION/$NEXT_SNAPSHOT/g" buildSrc/src/main/kotlin/litecommands-publish.gradle.kts
50+
jq ".versionSnapshot = \"$NEXT_SNAPSHOT\"" .github/release/version.json > t.json && mv t.json .github/release/version.json
4251
4352
# Commit & push Snapshot
44-
git commit -am "(Snapshot $NEXT_SNAPSHOT)"
53+
git commit -am "Snapshot $NEXT_SNAPSHOT"
4554
git push

.github/workflows/create-release.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ jobs:
2323
steps:
2424
- name: Checkout code
2525
uses: actions/checkout@v6
26+
with:
27+
persist-credentials: false
2628

2729
- name: Calculate New Version
2830
id: vars
2931
run: |
3032
# Parse versions from JSON
31-
OLD_RELEASE=$(jq -r '.versionRelease' .github/version.json)
32-
VERSION_SNAPSHOT=$(jq -r '.versionSnapshot' .github/version.json)
33+
OLD_RELEASE=$(jq -r '.versionRelease' .github/release/version.json)
34+
VERSION_SNAPSHOT=$(jq -r '.versionSnapshot' .github/release/version.json)
3335
3436
# Split into version parts
3537
IFS='.' read -ra ADDR <<< "$OLD_RELEASE"
@@ -55,14 +57,14 @@ jobs:
5557
- name: Update Files
5658
run: |
5759
NEW_RELEASE="${{ steps.vars.outputs.NEW_RELEASE }}"
58-
OLD_REL="${{ steps.vars.outputs.OLD_RELEASE }}"
60+
OLD_RELEASE="${{ steps.vars.outputs.OLD_RELEASE }}"
5961
VERSION_SNAPSHOT="${{ steps.vars.outputs.VERSION_SNAPSHOT }}"
6062
6163
# Global update all files (old release -> new release)
6264
grep -rl "$OLD_RELEASE" . --exclude-dir=.git --exclude=*.yml | xargs sed -i "s/$OLD_RELEASE/$NEW_RELEASE/g"
6365
64-
# Update .github/version.json
65-
jq ".versionRelease = \"$NEW_RELEASE\"" .github/version.json > temp.json && mv temp.json .github/version.json
66+
# Update .github/release/version.json
67+
jq ".versionRelease = \"$NEW_RELEASE\"" .github/release/version.json > temp.json && mv temp.json .github/release/version.json
6668
6769
# Update gradle.kts (snapshot -> release)
6870
sed -i "s/$VERSION_SNAPSHOT/$NEW_RELEASE/g" buildSrc/src/main/kotlin/litecommands-publish.gradle.kts

0 commit comments

Comments
 (0)