forked from Anime-Gaming-Cafe/AGC-Utils
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (104 loc) · 3.8 KB
/
release.yml
File metadata and controls
130 lines (104 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: 📦 Auto Patch Release & Build
on:
push:
branches:
- main
concurrency:
group: codeql-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
patch-build-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x'
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Get latest tag
id: latest_tag
run: |
LATEST=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n 1)
echo "latest_tag=$LATEST" >> $GITHUB_OUTPUT
- name: Generate next patch version
id: taggen
run: |
CURRENT_TAG=$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || true)
if [[ -n "$CURRENT_TAG" ]]; then
echo "🔁 Commit already has tag: $CURRENT_TAG"
echo "new_tag=$CURRENT_TAG" >> $GITHUB_OUTPUT
echo "skip_tagging=true" >> $GITHUB_OUTPUT
exit 0
fi
BASE=${{ steps.latest_tag.outputs.latest_tag }}
if [[ "$BASE" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
NEW_TAG="v${major}.${minor}.$((patch + 1))"
echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
echo "skip_tagging=false" >> $GITHUB_OUTPUT
else
echo "Invalid tag format: $BASE"
exit 1
fi
- name: Create and push tag
if: steps.taggen.outputs.skip_tagging == 'false'
run: |
git tag ${{ steps.taggen.outputs.new_tag }}
git push origin ${{ steps.taggen.outputs.new_tag }}
- name: Build and zip for all OS/Arch combos
run: |
VERSION=${{ steps.taggen.outputs.new_tag }}
PLATFORMS=(
"linux-x64"
"linux-arm64"
"win-x64"
"win-arm64"
)
for RID in "${PLATFORMS[@]}"; do
echo "▶ Cleaning up old artifacts..."
rm -rf publish/
echo "▶ Building for $RID..."
OUTDIR="publish/$RID"
dotnet publish -c Release -r "$RID" -o "$OUTDIR" --self-contained false -p:InformationalVer="$VERSION"
OS=$(echo $RID | cut -d'-' -f1)
ARCH=$(echo $RID | cut -d'-' -f2)
ZIP_NAME="AGC_Management_${OS}_${ARCH}_${VERSION}.zip"
echo "📦 Creating $ZIP_NAME..."
cd "$OUTDIR"
zip -r "../../$ZIP_NAME" .
cd - > /dev/null
done
- name: Create GitHub Release with Artifacts
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.taggen.outputs.new_tag }}
name: ${{ steps.taggen.outputs.new_tag }}
draft: false
generate_release_notes: true
files: |
AGC_Management_linux_*.zip
AGC_Management_win_*.zip
- name: "Send Release Notification to Discord"
uses: tsickert/discord-webhook@v7.0.0
with:
webhook-url: ${{ secrets.REL_DISCORD_WEBHOOK_URL }}
content: |
**New Patch Release Created!** :tada:
- **Version:** ${{ steps.taggen.outputs.new_tag }}
- name: Trigger Deploy Workflow
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: trigger-deploy
client-payload: '{"tag": "${{ steps.taggen.outputs.new_tag }}"}'