Skip to content

Commit 7848fb3

Browse files
committed
Update release Webhook
1 parent 8c590c1 commit 7848fb3

File tree

3 files changed

+147
-12
lines changed

3 files changed

+147
-12
lines changed

.github/workflows/release.yml

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@ name: Release to CurseForge and Modrinth
22

33
on:
44
release:
5-
types: [created]
5+
types: [created, published]
6+
workflow_dispatch:
7+
inputs:
8+
release_tag:
9+
description: 'Release tag to process (e.g., v1.20.4)'
10+
required: false
11+
type: string
612

713
jobs:
814
build-and-release:
915
runs-on: ubuntu-latest
1016
steps:
1117
- name: Checkout code
1218
uses: actions/checkout@v3
19+
with:
20+
# If workflow_dispatch, checkout the tag
21+
ref: ${{ github.event.inputs.release_tag || github.ref }}
1322

1423
- name: Set up JDK 17
1524
uses: actions/setup-java@v3
@@ -24,8 +33,26 @@ jobs:
2433
- name: Get artifact info
2534
id: artifact
2635
run: |
36+
# For workflow_dispatch, use the input tag, otherwise use the ref name
37+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
38+
VERSION="${{ github.event.inputs.release_tag }}"
39+
else
40+
VERSION="${GITHUB_REF_NAME}"
41+
fi
42+
VERSION="${VERSION#v}" # Remove 'v' prefix if present
2743
echo "jar_path=$(find target/ -name 'MinecraftServerAPI-*.jar' | head -n 1)" >> $GITHUB_OUTPUT
28-
echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
44+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
45+
echo "Processing version: ${VERSION}"
46+
47+
- name: Extract game version from branch or tag
48+
id: game_version
49+
run: |
50+
# Get the version for game-versions field
51+
VERSION="${{ steps.artifact.outputs.version }}"
52+
# Extract just the Minecraft version (e.g., 1.20.4 from v1.20.4)
53+
MC_VERSION=$(echo "$VERSION" | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?')
54+
echo "minecraft_version=${MC_VERSION}" >> $GITHUB_OUTPUT
55+
echo "Minecraft version: ${MC_VERSION}"
2956
3057
- name: Upload to Modrinth & Curseforge
3158
uses: Kir-Antipov/mc-publish@v3.3
@@ -38,21 +65,26 @@ jobs:
3865

3966
files: ${{ steps.artifact.outputs.jar_path }}
4067

41-
name: MinecraftServerAPI ${{ github.ref_name }}
68+
name: MinecraftServerAPI ${{ steps.artifact.outputs.version }}
4269
version: msa-${{ steps.artifact.outputs.version }}
4370
version-type: release
4471
game-versions: |
45-
>=1.21
72+
${{ steps.game_version.outputs.minecraft_version }}
4673
loaders: |
4774
paper
4875
spigot
4976
bukkit
5077
changelog: |
51-
See [GitHub Release](${{ github.event.release.html_url }}) for changelog.
52-
53-
- name: Upload to release
54-
uses: softprops/action-gh-release@v1
55-
with:
56-
files: target/MinecraftServerAPI-*.jar
57-
env:
58-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
## MinecraftServerAPI v${{ steps.artifact.outputs.version }}
79+
80+
### Changes
81+
- Rebased on latest master branch
82+
- Includes all current features and bugfixes
83+
84+
### Minecraft Version
85+
Supports Minecraft ${{ steps.game_version.outputs.minecraft_version }}
86+
87+
### Installation
88+
Download the JAR file and place it in your Minecraft server's `plugins` folder.
89+
90+
For full documentation, see: https://github.com/${{ github.repository }}

rebase-and-release.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ See [README.md](https://github.com/$(gh repo view --json nameWithOwner -q .nameW
208208
"$JAR_FILE#MinecraftServerAPI-$VERSION.jar" > /dev/null 2>&1; then
209209

210210
log_success "Release $TAG_NAME successfully created!"
211+
212+
# Trigger the release workflow manually since gh CLI doesn't trigger it automatically
213+
log_info "Triggering release workflow for $TAG_NAME..."
214+
if gh workflow run release.yml -f release_tag="$TAG_NAME" --ref master > /dev/null 2>&1; then
215+
log_success "Release workflow triggered for $TAG_NAME"
216+
else
217+
log_warning "Could not trigger release workflow for $TAG_NAME (manual trigger may be needed)"
218+
fi
219+
211220
SUCCESSFUL_RELEASES+=("$VERSION")
212221
else
213222
log_error "Failed to create release $TAG_NAME!"

trigger-release-workflow.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
3+
# Script to manually trigger the release workflow for all existing releases
4+
# This is needed because releases created via gh CLI don't automatically trigger workflows
5+
6+
set -e
7+
8+
# Colors for output
9+
RED='\033[0;31m'
10+
GREEN='\033[0;32m'
11+
YELLOW='\033[1;33m'
12+
BLUE='\033[0;34m'
13+
NC='\033[0m' # No Color
14+
15+
# Logging functions
16+
log_info() {
17+
printf "${BLUE}[INFO]${NC} %s\n" "$1"
18+
}
19+
20+
log_success() {
21+
printf "${GREEN}[SUCCESS]${NC} %s\n" "$1"
22+
}
23+
24+
log_warning() {
25+
printf "${YELLOW}[WARNING]${NC} %s\n" "$1"
26+
}
27+
28+
log_error() {
29+
printf "${RED}[ERROR]${NC} %s\n" "$1"
30+
}
31+
32+
# Check if gh is installed
33+
if ! command -v gh &> /dev/null; then
34+
log_error "GitHub CLI (gh) is not installed. Please install it with: brew install gh"
35+
exit 1
36+
fi
37+
38+
# Check if we're authenticated
39+
if ! gh auth status &> /dev/null; then
40+
log_error "Not authenticated with GitHub. Please run 'gh auth login'."
41+
exit 1
42+
fi
43+
44+
log_info "Fetching all releases..."
45+
46+
# Get all releases
47+
RELEASES=$(gh release list --limit 100 --json tagName,name -q '.[] | .tagName')
48+
49+
if [ -z "$RELEASES" ]; then
50+
log_warning "No releases found!"
51+
exit 0
52+
fi
53+
54+
log_info "Found releases:"
55+
echo "$RELEASES" | while read -r tag; do
56+
printf " - %s\n" "$tag"
57+
done
58+
59+
printf "\n"
60+
log_info "Triggering release workflow for each release..."
61+
printf "\n"
62+
63+
SUCCESS_COUNT=0
64+
FAIL_COUNT=0
65+
66+
for TAG in $RELEASES; do
67+
log_info "Processing release: $TAG"
68+
69+
# Trigger workflow dispatch for this release
70+
if gh workflow run release.yml \
71+
-f release_tag="$TAG" \
72+
--ref main > /dev/null 2>&1; then
73+
log_success "Workflow triggered for $TAG"
74+
((SUCCESS_COUNT++))
75+
else
76+
log_error "Failed to trigger workflow for $TAG"
77+
((FAIL_COUNT++))
78+
fi
79+
done
80+
81+
printf "\n"
82+
printf "========================================\n"
83+
printf " SUMMARY \n"
84+
printf "========================================\n"
85+
printf "\n"
86+
87+
log_info "Successfully triggered: $SUCCESS_COUNT"
88+
log_info "Failed: $FAIL_COUNT"
89+
90+
if [ $FAIL_COUNT -eq 0 ]; then
91+
log_success "All workflows triggered successfully! 🎉"
92+
else
93+
log_warning "Some workflows failed to trigger. Check the errors above."
94+
fi

0 commit comments

Comments
 (0)