Build Release #4
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: Build Release | |
| # Primary path: on main, create + push a version tag → draft release with zip. | |
| # git checkout main && git pull | |
| # git tag v0.1.0 | |
| # git push origin v0.1.0 | |
| # Then open the draft on GitHub, paste release notes, Publish. | |
| # | |
| # Manual rebuild: Actions → Build Release → Run workflow. | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Mod version (used for the zip name / release tag)" | |
| required: true | |
| default: "0.1.0" | |
| game_version: | |
| description: "Vintage Story version to build against" | |
| required: true | |
| default: "1.22.0" | |
| permissions: | |
| contents: write | |
| env: | |
| MOD_ID: burdened | |
| CSPROJ: Burdened.csproj | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Require tag to point at main | |
| if: startsWith(github.ref, 'refs/tags/') | |
| shell: bash | |
| run: | | |
| git fetch origin main | |
| if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then | |
| echo "::error::Tag ${{ github.ref_name }} does not point at a commit on main. Create the tag from main and push it again." | |
| exit 1 | |
| fi | |
| echo "Tag ${{ github.ref_name }} → $GITHUB_SHA is on main." | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: "10.0.x" | |
| - name: Resolve versions | |
| id: vars | |
| shell: bash | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| GAME_VERSION="${{ github.event.inputs.game_version }}" | |
| else | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| GAME_VERSION="$(jq -r '.dependencies.game' resources/modinfo.json)" | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "game_version=$GAME_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "tag=v$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Building $MOD_ID v$VERSION against game $GAME_VERSION" | |
| - name: Download Vintage Story server | |
| shell: bash | |
| run: | | |
| GAME_VERSION="${{ steps.vars.outputs.game_version }}" | |
| URL="https://cdn.vintagestory.at/gamefiles/stable/vs_server_linux-x64_${GAME_VERSION}.tar.gz" | |
| echo "Fetching $URL" | |
| mkdir -p "$RUNNER_TEMP/vs" | |
| curl -fSL "$URL" -o "$RUNNER_TEMP/vs_server.tar.gz" | |
| tar -xzf "$RUNNER_TEMP/vs_server.tar.gz" -C "$RUNNER_TEMP/vs" | |
| echo "VINTAGE_STORY=$RUNNER_TEMP/vs" >> "$GITHUB_ENV" | |
| - name: Stamp version into modinfo.json | |
| shell: bash | |
| run: | | |
| VERSION="${{ steps.vars.outputs.version }}" | |
| tmp="$(mktemp)" | |
| jq --arg v "$VERSION" '.version = $v' resources/modinfo.json > "$tmp" | |
| mv "$tmp" resources/modinfo.json | |
| cat resources/modinfo.json | |
| - name: Build | |
| run: dotnet build $CSPROJ -c Release | |
| - name: Package | |
| id: package | |
| shell: bash | |
| run: | | |
| VERSION="${{ steps.vars.outputs.version }}" | |
| ZIP_NAME="${MOD_ID}_${VERSION}.zip" | |
| mkdir -p Releases | |
| # Zip the build output (DLL + modinfo.json + assets), skipping debug files. | |
| ( cd bin/Release && zip -r "$GITHUB_WORKSPACE/Releases/$ZIP_NAME" . -x '*.pdb' -x '*.deps.json' ) | |
| echo "zip_name=$ZIP_NAME" >> "$GITHUB_OUTPUT" | |
| echo "zip_path=Releases/$ZIP_NAME" >> "$GITHUB_OUTPUT" | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.package.outputs.zip_name }} | |
| path: ${{ steps.package.outputs.zip_path }} | |
| # Draft so the zip is ready immediately; edit notes on GitHub, then Publish. | |
| - name: Create draft release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.vars.outputs.tag }} | |
| name: ${{ steps.vars.outputs.tag }} | |
| target_commitish: ${{ github.sha }} | |
| draft: true | |
| generate_release_notes: false | |
| files: ${{ steps.package.outputs.zip_path }} | |
| body: | | |
| <!-- Draft — paste the matching section from CHANGELOG.md, then Publish. --> |