Release #2
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 | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump: | |
| description: "Version bump type" | |
| required: false | |
| default: "patch" | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| permissions: | |
| contents: write | |
| env: | |
| DOTNET_VERSION: "8.0.x" | |
| SOLUTION_DIR: "Source/LocalNetAppChat" | |
| jobs: | |
| prepare: | |
| name: Determine version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| tag: ${{ steps.version.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Calculate next version | |
| id: version | |
| run: | | |
| BUMP="${{ github.event.inputs.bump || 'patch' }}" | |
| # Find latest semver tag (vX.Y.Z format) | |
| LATEST_SEMVER=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-version:refname | head -n1) | |
| if [ -z "$LATEST_SEMVER" ]; then | |
| # No semver tags yet. Check for legacy tags (v1.XX format) | |
| LATEST_LEGACY=$(git tag --list 'v[0-9]*.[0-9]*' --sort=-version:refname | head -n1) | |
| if [ -n "$LATEST_LEGACY" ]; then | |
| # Convert legacy tag to semver starting point | |
| LEGACY_NUM=$(echo "$LATEST_LEGACY" | sed 's/^v//') | |
| MAJOR=$(echo "$LEGACY_NUM" | cut -d. -f1) | |
| MINOR=$(echo "$LEGACY_NUM" | cut -d. -f2) | |
| CURRENT="${MAJOR}.${MINOR}.0" | |
| echo "Found legacy tag $LATEST_LEGACY, using $CURRENT as base" | |
| else | |
| CURRENT="1.0.0" | |
| echo "No tags found, starting at $CURRENT" | |
| fi | |
| else | |
| CURRENT=$(echo "$LATEST_SEMVER" | sed 's/^v//') | |
| echo "Found semver tag $LATEST_SEMVER" | |
| fi | |
| MAJOR=$(echo "$CURRENT" | cut -d. -f1) | |
| MINOR=$(echo "$CURRENT" | cut -d. -f2) | |
| PATCH=$(echo "$CURRENT" | cut -d. -f3) | |
| case "$BUMP" in | |
| major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; | |
| minor) MINOR=$((MINOR + 1)); PATCH=0 ;; | |
| patch) PATCH=$((PATCH + 1)) ;; | |
| esac | |
| VERSION="${MAJOR}.${MINOR}.${PATCH}" | |
| TAG="v${VERSION}" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "Next version: $VERSION (tag: $TAG), bump: $BUMP" | |
| test: | |
| name: Run tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Restore | |
| run: dotnet restore | |
| working-directory: ${{ env.SOLUTION_DIR }} | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore | |
| working-directory: ${{ env.SOLUTION_DIR }} | |
| - name: Test | |
| run: dotnet test --configuration Release --no-build --verbosity normal | |
| working-directory: ${{ env.SOLUTION_DIR }} | |
| release: | |
| name: Build & Release (${{ matrix.component }}, ${{ matrix.rid }}) | |
| needs: [prepare, test] | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Server | |
| - component: server | |
| project: LocalNetAppChat.Server/LocalNetAppChat.Server.csproj | |
| os: ubuntu-latest | |
| rid: linux-x64 | |
| artifact: lnac-server-linux-x64 | |
| - component: server | |
| project: LocalNetAppChat.Server/LocalNetAppChat.Server.csproj | |
| os: windows-latest | |
| rid: win-x64 | |
| artifact: lnac-server-win-x64 | |
| # Client | |
| - component: client | |
| project: LocalNetAppChat.ConsoleClient/LocalNetAppChat.ConsoleClient.csproj | |
| os: ubuntu-latest | |
| rid: linux-x64 | |
| artifact: lnac-client-linux-x64 | |
| - component: client | |
| project: LocalNetAppChat.ConsoleClient/LocalNetAppChat.ConsoleClient.csproj | |
| os: windows-latest | |
| rid: win-x64 | |
| artifact: lnac-client-win-x64 | |
| # Bot | |
| - component: bot | |
| project: LocalNetAppChat.Bot/LocalNetAppChat.Bot.csproj | |
| os: ubuntu-latest | |
| rid: linux-x64 | |
| artifact: lnac-bot-linux-x64 | |
| - component: bot | |
| project: LocalNetAppChat.Bot/LocalNetAppChat.Bot.csproj | |
| os: windows-latest | |
| rid: win-x64 | |
| artifact: lnac-bot-win-x64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Restore | |
| run: dotnet restore | |
| working-directory: ${{ env.SOLUTION_DIR }} | |
| - name: Publish | |
| run: >- | |
| dotnet publish ${{ matrix.project }} | |
| -c Release | |
| -o ${{ matrix.artifact }} | |
| -r ${{ matrix.rid }} | |
| -p:PublishReadyToRun=true | |
| -p:PublishSingleFile=true | |
| -p:IncludeNativeLibrariesForSelfExtract=true | |
| -p:UseAppHost=true | |
| -p:Version=${{ needs.prepare.outputs.version }} | |
| --self-contained true | |
| working-directory: ${{ env.SOLUTION_DIR }} | |
| - name: Create archive | |
| uses: vimtor/action-zip@v1 | |
| with: | |
| files: ${{ env.SOLUTION_DIR }}/${{ matrix.artifact }}/ | |
| dest: ${{ matrix.artifact }}.zip | |
| - name: Upload to release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.prepare.outputs.tag }} | |
| name: "LNAC ${{ needs.prepare.outputs.tag }}" | |
| generate_release_notes: true | |
| files: ${{ matrix.artifact }}.zip |