forked from Rainson12/FactorioSaveGameEnableAchievements
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (84 loc) · 2.76 KB
/
release-windows-dotnet.yml
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
name: .NET Windows Release 🚀
on:
push:
branches:
- master
workflow_dispatch: # Allows manual execution
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all existing tags
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Build Project
run: dotnet build --configuration Release
- name: Publish Artifacts
run: |
mkdir release
dotnet publish -c Release -o release
- name: Create Zip Archive
run: zip -r release.zip release/
# Detect changes in the .github directory
- name: Check for .github changes
id: changes
run: |
if git diff --name-only HEAD^ | grep '^\.github/'; then
echo "changes_in_github=true" >> $GITHUB_ENV
else
echo "changes_in_github=false" >> $GITHUB_ENV
fi
# Apply label if changes are detected in .github
- name: Label PR with ignore-changelog
if: env.changes_in_github == 'true' && github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const pr = context.payload.pull_request;
if (pr) {
github.rest.issues.addLabels({
owner,
repo,
issue_number: pr.number,
labels: ['ignore-changelog']
});
}
- name: Generate Version Tag
id: tag
run: |
GAME_VERSION="2.0.28"
LATEST_TAG=$(git tag --sort=-v:refname | grep "^${GAME_VERSION}-" | head -n 1)
if [ -z "$LATEST_TAG" ]; then
NEW_TAG="${GAME_VERSION}-1.0"
else
LAST_VERSION=$(echo $LATEST_TAG | awk -F '-' '{print $2}')
NEW_VERSION=$(echo "$LAST_VERSION + 0.1" | bc)
NEW_TAG="${GAME_VERSION}-$(printf %.1f $NEW_VERSION)"
fi
echo "NEW_TAG=$NEW_TAG"
git tag $NEW_TAG
git push origin $NEW_TAG
echo "tag=$NEW_TAG" >> $GITHUB_ENV
- name: Draft Release
id: draft_release
uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.tag }}
name: "Release ${{ env.tag }}"
body: ${{ steps.draft_release.outputs.body }}
artifacts: "release.zip"
draft: false
prerelease: false