|
| 1 | +name: Release SurfTimer.Plugin |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" # auto trigger on tags like v1.2.3 |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: "Tag to release (e.g., v1.2.3)" |
| 11 | + required: true |
| 12 | + default: "v0.0.0" |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Resolve release tag |
| 23 | + id: vars |
| 24 | + shell: bash |
| 25 | + run: | |
| 26 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 27 | + TAG="${{ github.event.inputs.tag }}" |
| 28 | + else |
| 29 | + TAG="${{ github.ref_name }}" |
| 30 | + fi |
| 31 | + if ! echo "$TAG" | grep -Eq '^v[0-9]'; then |
| 32 | + echo "Tag must start with 'v' (e.g., v1.2.3). Got: $TAG" |
| 33 | + exit 1 |
| 34 | + fi |
| 35 | + echo "RELEASE_TAG=$TAG" >> $GITHUB_ENV |
| 36 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 37 | +
|
| 38 | + # Checkout plugin repo at the tag |
| 39 | + - name: Checkout plugin repository (Timer) |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + path: Timer |
| 43 | + ref: ${{ env.RELEASE_TAG }} |
| 44 | + |
| 45 | + # Checkout SurfTimer.Shared as sibling folder (ProjectReference resolves via ../../SurfTimer.Shared) |
| 46 | + - name: Checkout SurfTimer.Shared |
| 47 | + uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + repository: tslashd/SurfTimer.Shared |
| 50 | + path: SurfTimer.Shared |
| 51 | + # If private: |
| 52 | + # token: ${{ secrets.SHARED_REPO_PAT }} |
| 53 | + # Optionally pin to a tag/commit: |
| 54 | + # ref: vX.Y.Z |
| 55 | + |
| 56 | + - name: Setup .NET 8 |
| 57 | + uses: actions/setup-dotnet@v4 |
| 58 | + with: |
| 59 | + dotnet-version: 8.0.x |
| 60 | + |
| 61 | + # From Timer/src, ProjectReference ../../SurfTimer.Shared/... resolves correctly |
| 62 | + - name: Restore (plugin) |
| 63 | + working-directory: Timer/src |
| 64 | + run: dotnet restore SurfTimer.Plugin.csproj |
| 65 | + |
| 66 | + - name: Build (Release) |
| 67 | + working-directory: Timer/src |
| 68 | + run: dotnet build SurfTimer.Plugin.csproj -c Release --no-restore |
| 69 | + |
| 70 | + - name: Prepare package layout |
| 71 | + id: prep |
| 72 | + shell: bash |
| 73 | + env: |
| 74 | + OUT_ROOT: out |
| 75 | + run: | |
| 76 | + set -euo pipefail |
| 77 | +
|
| 78 | + BIN="Timer/src/bin/Release/net8.0" |
| 79 | + PKG="$OUT_ROOT" |
| 80 | + ADDONS="$PKG/addons/SurfTimer.Plugin" |
| 81 | + CFGDST="$PKG/cfg/SurfTimer" |
| 82 | +
|
| 83 | + mkdir -p "$ADDONS/data/GeoIP" "$ADDONS/lang" "$CFGDST" |
| 84 | +
|
| 85 | + echo "Build output listing (should contain only selected DLLs):" |
| 86 | + ls -la "$BIN" |
| 87 | +
|
| 88 | + # Required artifacts (these should exist thanks to your KeepOnlySelectedDlls target) |
| 89 | + for f in SurfTimer.Plugin.dll SurfTimer.Shared.dll Dapper.dll MaxMind.Db.dll MaxMind.GeoIP2.dll MySqlConnector.dll; do |
| 90 | + test -f "$BIN/$f" || { echo "Missing $f in $BIN"; exit 1; } |
| 91 | + done |
| 92 | +
|
| 93 | + # Copy all dlls that remain after your KeepOnlySelectedDlls pruning |
| 94 | + cp -v "$BIN"/*.dll "$ADDONS/" |
| 95 | +
|
| 96 | + # data/GeoIP |
| 97 | + SRC_MMDB="Timer/data/GeoIP/GeoLite2-Country.mmdb" |
| 98 | + test -f "$SRC_MMDB" || { echo "Missing $SRC_MMDB"; exit 1; } |
| 99 | + cp -v "$SRC_MMDB" "$ADDONS/data/GeoIP/" |
| 100 | +
|
| 101 | + # lang/en.json |
| 102 | + SRC_LANG="Timer/lang/en.json" |
| 103 | + test -f "$SRC_LANG" || { echo "Missing $SRC_LANG"; exit 1; } |
| 104 | + cp -v "$SRC_LANG" "$ADDONS/lang/" |
| 105 | +
|
| 106 | + # cfg/SurfTimer (copy entire folder) |
| 107 | + test -d "Timer/cfg/SurfTimer" || { echo "Missing Timer/cfg/SurfTimer"; exit 1; } |
| 108 | + cp -vr "Timer/cfg/SurfTimer/." "$CFGDST/" |
| 109 | +
|
| 110 | + echo "PKG_PATH=$PKG" >> $GITHUB_OUTPUT |
| 111 | +
|
| 112 | + - name: Create ZIP |
| 113 | + shell: bash |
| 114 | + env: |
| 115 | + PKG_NAME: SurfTimer.Plugin-${{ env.RELEASE_TAG }} |
| 116 | + run: | |
| 117 | + cd out |
| 118 | + # zip the *contents* so archive root is addons/ and cfg/ |
| 119 | + zip -r "${PKG_NAME}.zip" addons cfg |
| 120 | + sha256sum "${PKG_NAME}.zip" > "${PKG_NAME}.zip.sha256" |
| 121 | + ls -la |
| 122 | +
|
| 123 | + - name: Upload artifact |
| 124 | + uses: actions/upload-artifact@v4 |
| 125 | + with: |
| 126 | + name: SurfTimer.Plugin-${{ env.RELEASE_TAG }} |
| 127 | + path: | |
| 128 | + out/SurfTimer.Plugin-${{ env.RELEASE_TAG }}.zip |
| 129 | + out/SurfTimer.Plugin-${{ env.RELEASE_TAG }}.zip.sha256 |
| 130 | +
|
| 131 | + release: |
| 132 | + runs-on: ubuntu-latest |
| 133 | + needs: build |
| 134 | + steps: |
| 135 | + - name: Download artifacts |
| 136 | + uses: actions/download-artifact@v4 |
| 137 | + with: |
| 138 | + path: ./artifacts |
| 139 | + |
| 140 | + - name: Determine tag |
| 141 | + id: vars |
| 142 | + shell: bash |
| 143 | + run: | |
| 144 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 145 | + TAG="${{ github.event.inputs.tag }}" |
| 146 | + else |
| 147 | + TAG="${{ github.ref_name }}" |
| 148 | + fi |
| 149 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 150 | + echo "RELEASE_TAG=$TAG" >> $GITHUB_ENV |
| 151 | +
|
| 152 | + - name: List artifacts |
| 153 | + run: ls -R ./artifacts |
| 154 | + |
| 155 | + - name: Create GitHub Release and upload assets |
| 156 | + uses: softprops/action-gh-release@v2 |
| 157 | + with: |
| 158 | + tag_name: ${{ steps.vars.outputs.tag }} |
| 159 | + name: SurfTimer.Plugin ${{ steps.vars.outputs.tag }} |
| 160 | + draft: false |
| 161 | + prerelease: ${{ contains(steps.vars.outputs.tag, '-rc') || contains(steps.vars.outputs.tag, '-beta') || contains(steps.vars.outputs.tag, '-alpha') }} |
| 162 | + files: | |
| 163 | + artifacts/SurfTimer.Plugin-${{ env.RELEASE_TAG }}/SurfTimer.Plugin-${{ env.RELEASE_TAG }}.zip |
| 164 | + artifacts/SurfTimer.Plugin-${{ env.RELEASE_TAG }}/SurfTimer.Plugin-${{ env.RELEASE_TAG }}.zip.sha256 |
| 165 | + env: |
| 166 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments