-
-
Notifications
You must be signed in to change notification settings - Fork 12
166 lines (141 loc) · 5.32 KB
/
release.yml
File metadata and controls
166 lines (141 loc) · 5.32 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Release SurfTimer.Plugin
on:
push:
tags:
- "v*.*.*" # auto trigger on tags like v1.2.3
workflow_dispatch:
inputs:
tag:
description: "Tag to release (e.g., v1.2.3)"
required: true
default: "v0.0.0"
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Resolve release tag
id: vars
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG="${{ github.ref_name }}"
fi
if ! echo "$TAG" | grep -Eq '^v[0-9]'; then
echo "Tag must start with 'v' (e.g., v1.2.3). Got: $TAG"
exit 1
fi
echo "RELEASE_TAG=$TAG" >> $GITHUB_ENV
echo "tag=$TAG" >> $GITHUB_OUTPUT
# Checkout plugin repo at the tag
- name: Checkout plugin repository (Timer)
uses: actions/checkout@v6
with:
path: Timer
ref: ${{ env.RELEASE_TAG }}
# Checkout SurfTimer.Shared as sibling folder (ProjectReference resolves via ../../SurfTimer.Shared)
- name: Checkout SurfTimer.Shared
uses: actions/checkout@v6
with:
repository: tslashd/SurfTimer.Shared
path: SurfTimer.Shared
# If private:
# token: ${{ secrets.SHARED_REPO_PAT }}
# Optionally pin to a tag/commit:
# ref: vX.Y.Z
- name: Setup .NET 8
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
# From Timer/src, ProjectReference ../../SurfTimer.Shared/... resolves correctly
- name: Restore (plugin)
working-directory: Timer/src
run: dotnet restore SurfTimer.Plugin.csproj
- name: Build (Release)
working-directory: Timer/src
run: dotnet build SurfTimer.Plugin.csproj -c Release --no-restore
- name: Prepare package layout
id: prep
shell: bash
env:
OUT_ROOT: out
run: |
set -euo pipefail
BIN="Timer/src/bin/Release/net8.0"
PKG="$OUT_ROOT"
ADDONS="$PKG/addons/SurfTimer.Plugin"
CFGDST="$PKG/cfg/SurfTimer"
mkdir -p "$ADDONS/data/GeoIP" "$ADDONS/lang" "$CFGDST"
echo "Build output listing (should contain only selected DLLs):"
ls -la "$BIN"
# Required artifacts (these should exist thanks to your KeepOnlySelectedDlls target)
for f in SurfTimer.Plugin.dll SurfTimer.Shared.dll Dapper.dll MaxMind.Db.dll MaxMind.GeoIP2.dll MySqlConnector.dll; do
test -f "$BIN/$f" || { echo "Missing $f in $BIN"; exit 1; }
done
# Copy all dlls that remain after your KeepOnlySelectedDlls pruning
cp -v "$BIN"/*.dll "$ADDONS/"
# data/GeoIP
SRC_MMDB="Timer/data/GeoIP/GeoLite2-Country.mmdb"
test -f "$SRC_MMDB" || { echo "Missing $SRC_MMDB"; exit 1; }
cp -v "$SRC_MMDB" "$ADDONS/data/GeoIP/"
# lang/en.json
SRC_LANG="Timer/lang/en.json"
test -f "$SRC_LANG" || { echo "Missing $SRC_LANG"; exit 1; }
cp -v "$SRC_LANG" "$ADDONS/lang/"
# cfg/SurfTimer (copy entire folder)
test -d "Timer/cfg/SurfTimer" || { echo "Missing Timer/cfg/SurfTimer"; exit 1; }
cp -vr "Timer/cfg/SurfTimer/." "$CFGDST/"
echo "PKG_PATH=$PKG" >> $GITHUB_OUTPUT
- name: Create ZIP
shell: bash
env:
PKG_NAME: SurfTimer.Plugin-${{ env.RELEASE_TAG }}
run: |
cd out
# zip the *contents* so archive root is addons/ and cfg/
zip -r "${PKG_NAME}.zip" addons cfg
sha256sum "${PKG_NAME}.zip" > "${PKG_NAME}.zip.sha256"
ls -la
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: SurfTimer.Plugin-${{ env.RELEASE_TAG }}
path: |
out/SurfTimer.Plugin-${{ env.RELEASE_TAG }}.zip
out/SurfTimer.Plugin-${{ env.RELEASE_TAG }}.zip.sha256
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: ./artifacts
- name: Determine tag
id: vars
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG="${{ github.ref_name }}"
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "RELEASE_TAG=$TAG" >> $GITHUB_ENV
- name: List artifacts
run: ls -R ./artifacts
- name: Create GitHub Release and upload assets
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.vars.outputs.tag }}
name: SurfTimer.Plugin ${{ steps.vars.outputs.tag }}
draft: false
prerelease: ${{ contains(steps.vars.outputs.tag, '-rc') || contains(steps.vars.outputs.tag, '-beta') || contains(steps.vars.outputs.tag, '-alpha') }}
files: |
artifacts/SurfTimer.Plugin-${{ env.RELEASE_TAG }}/SurfTimer.Plugin-${{ env.RELEASE_TAG }}.zip
artifacts/SurfTimer.Plugin-${{ env.RELEASE_TAG }}/SurfTimer.Plugin-${{ env.RELEASE_TAG }}.zip.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}