release wf #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| # Plugin repository (Timer) at the specific tag | |
| - name: Checkout plugin repository (Timer) | |
| uses: actions/checkout@v4 | |
| with: | |
| path: Timer | |
| ref: ${{ env.RELEASE_TAG }} | |
| # Shared repository as a sibling folder in the workspace root | |
| - name: Checkout SurfTimer.Shared | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: tslashd/SurfTimer.Shared | |
| path: SurfTimer.Shared | |
| # If private: | |
| # token: ${{ secrets.SHARED_REPO_PAT }} | |
| # Optionally pin a version: | |
| # ref: vX.Y.Z | |
| - name: Setup .NET 8 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x | |
| # --- IMPORTANT --- | |
| # From Timer/src, the ProjectReference ../../SurfTimer.Shared/SurfTimer.Shared.csproj 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/package | |
| 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" | |
| # Validate main artifacts | |
| test -f "$BIN/SurfTimer.Plugin.dll" || (echo "Missing SurfTimer.Plugin.dll in $BIN" && exit 1) | |
| test -f "$BIN/SurfTimer.Shared.dll" || (echo "Missing SurfTimer.Shared.dll in $BIN (check ProjectReference path)" && exit 1) | |
| # Copy required DLLs | |
| cp -v "$BIN"/Dapper.dll "$ADDONS/" || true | |
| cp -v "$BIN"/MaxMind.Db.dll "$ADDONS/" || true | |
| cp -v "$BIN"/MaxMind.GeoIP2.dll "$ADDONS/" || true | |
| cp -v "$BIN"/MySqlConnector.dll "$ADDONS/" || true | |
| cp -v "$BIN"/SurfTimer.Plugin.dll "$ADDONS/" | |
| cp -v "$BIN"/SurfTimer.Shared.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 | |
| 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 -r "${PKG_NAME}.zip" "package" | |
| sha256sum "${PKG_NAME}.zip" > "${PKG_NAME}.zip.sha256" | |
| ls -la | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| 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@v4 | |
| 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@v2 | |
| 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 }} |