forked from kOchirasu/Maple2.File
-
Notifications
You must be signed in to change notification settings - Fork 8
94 lines (93 loc) · 3.56 KB
/
Copy pathrelease.yml
File metadata and controls
94 lines (93 loc) · 3.56 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
name: Release
on:
push:
branches: ["master"]
jobs:
check:
# Only ever run in the canonical repo, never in a fork.
if: github.repository == 'MS2Community/Maple2.File'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
should_release: ${{ steps.tag.outputs.should_release }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Read version from csproj
id: version
run: |
VERSION=$(grep -oPm1 '(?<=<PackageVersion>)[^<]+' Maple2.File.Parser/Maple2.File.Parser.csproj)
if [ -z "$VERSION" ]; then
echo "Could not read <PackageVersion> from csproj" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Detected version v$VERSION"
- name: Check whether tag already exists
id: tag
run: |
if git ls-remote --exit-code --tags origin "refs/tags/v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "Tag v${{ steps.version.outputs.version }} already exists; nothing to release."
echo "should_release=false" >> "$GITHUB_OUTPUT"
else
echo "Tag v${{ steps.version.outputs.version }} does not exist; will release."
echo "should_release=true" >> "$GITHUB_OUTPUT"
fi
release:
needs: check
if: needs.check.outputs.should_release == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
# Least privilege: only what is needed to push the tag and create the release.
permissions:
contents: write
env:
VERSION: ${{ needs.check.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Create and push tag
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git tag -a "v${VERSION}" -m "Release v${VERSION}"
git push origin "v${VERSION}"
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Pack
run: dotnet pack --configuration Release --output .
- name: Push
run: dotnet nuget push Maple2.File.Parser.Tadeucci.${VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN }}
- name: Check Available NuGet Package
uses: BMTLab/nuget-package-check-action@v1.5.3
with:
package: Maple2.File.Parser.Tadeucci
version: ${{ env.VERSION }}
attempts: 15
continue-on-error: true
- name: Send Discord Webhook
uses: hugoalh/send-discord-webhook-ghaction@v7.0.5
with:
key: ${{ secrets.DISCORD_WEBHOOK_URL }}
username: Github
avatar_url: https://cdn.discordapp.com/icons/1233581457470128209/e3ec579ceb94fa49d096e6dba0ef4931.webp
content: "New version published! <:widebeanhappy1:1234223129015091210><:widebeanhappy2:1234223164322611354><:widebeanhappy3:1234223182383284276>"
embeds: |
[
{
"title": "Maple2.File.Parser.Tadeucci",
"url": "https://www.nuget.org/packages/Maple2.File.Parser.Tadeucci",
"color": "rgb(87, 242, 135)",
}
]
- name: Create release
uses: softprops/action-gh-release@v3
with:
tag_name: v${{ env.VERSION }}
generate_release_notes: true
files: |
Maple2.File.Parser.Tadeucci.${{ env.VERSION }}.nupkg