Fixes issue where changes to branches in stack would not be saved (#391) #1040
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, test and release | |
| on: | |
| push: | |
| branches: ["main"] | |
| tags: ["v*.*.*"] | |
| paths-ignore: | |
| - README.md | |
| - CHANGELOG.md | |
| - .github/workflows/copilot-setup-steps.yml | |
| pull_request: | |
| branches: ["main"] | |
| paths-ignore: | |
| - README.md | |
| - CHANGELOG.md | |
| - .github/workflows/copilot-setup-steps.yml | |
| jobs: | |
| version: | |
| name: Get versioning information | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get_version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Get all tags | |
| - name: Get release version | |
| id: get_release_version | |
| uses: paulhatch/semantic-version@v5.4.0 | |
| with: | |
| tag_prefix: "v" | |
| version_format: "${major}.${minor}.${patch}" | |
| - name: Get branch names | |
| id: branch_names | |
| uses: OctopusDeploy/util-actions/current-branch-name@current-branch-name.0.1.0 | |
| - name: Get pre-release version | |
| id: get_pre_release_version | |
| uses: paulhatch/semantic-version@v5.4.0 | |
| with: | |
| tag_prefix: "v" | |
| version_format: "${major}.${minor}.${patch}-${{ steps.branch_names.outputs.branch_name }}.${{ github.run_number }}-${{ github.run_attempt }}" | |
| - name: Get version | |
| id: get_version | |
| run: echo "version=${{ github.ref_type == 'tag' && github.event_name == 'push' && steps.get_release_version.outputs.version || steps.get_pre_release_version.outputs.version }}" >> $GITHUB_OUTPUT | |
| build: | |
| needs: version | |
| strategy: | |
| matrix: | |
| include: | |
| - name: Linux | |
| os: ubuntu-latest | |
| - name: Windows | |
| os: windows-latest | |
| - name: macOS | |
| os: macos-latest | |
| name: Build and test on ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| working-directory: src | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --no-restore -c Release | |
| - name: Test | |
| run: dotnet test --no-build -c Release --verbosity normal --logger "trx;LogFileName=${{ github.workspace }}/tests/test_results.trx" | |
| - name: Create test report | |
| uses: phoenix-actions/test-reporting@v15 | |
| if: success() || failure() # run this step even if previous step failed | |
| with: | |
| name: Tests | |
| path: ${{ github.workspace }}/tests/*.trx | |
| path-replace-backslashes: true # Required for Windows paths | |
| reporter: dotnet-trx | |
| output-to: step-summary | |
| publish: | |
| needs: [version, build] | |
| strategy: | |
| matrix: | |
| include: | |
| - name: Linux amd64 | |
| runtime-id: linux-x64 | |
| artifact-name: linux_amd64 | |
| archive_type: tar | |
| os: ubuntu-latest | |
| - name: Linux arm64 | |
| runtime-id: linux-arm64 | |
| artifact-name: linux_arm64 | |
| archive_type: tar | |
| os: ubuntu-22.04-arm | |
| - name: Windows amd64 | |
| runtime-id: win-x64 | |
| artifact-name: windows_amd64 | |
| archive_type: zip | |
| os: windows-latest | |
| - name: Windows arm64 | |
| runtime-id: win-arm64 | |
| artifact-name: windows_arm64 | |
| archive_type: zip | |
| os: windows-latest | |
| - name: macOS amd64 | |
| runtime-id: osx-x64 | |
| artifact-name: macos_amd64 | |
| archive_type: tar | |
| os: macos-latest | |
| - name: macOS arm64 | |
| runtime-id: osx-arm64 | |
| artifact-name: macos_arm64 | |
| archive_type: tar | |
| os: macos-latest | |
| name: Publish ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Publish | |
| run: dotnet publish src/Stack/Stack.csproj -c Release -r ${{ matrix.runtime-id }} -p:Version=${{ needs.version.outputs.version }} -p:DebugType=None -p:DebugSymbols=false -o ${{ github.workspace }}/publish | |
| - name: Copy changelog to publish folder | |
| run: cp ${{ github.workspace }}/CHANGELOG.md ${{ github.workspace }}/publish | |
| - name: Copy readme to publish folder | |
| run: cp ${{ github.workspace }}/README.md ${{ github.workspace }}/publish | |
| - run: mkdir -p ${{ github.workspace }}/artifacts | |
| - name: Create tar.gz archive | |
| run: tar -czf ${{ github.workspace }}/artifacts/stack_${{ needs.version.outputs.version }}_${{ matrix.artifact-name }}.tar.gz * | |
| working-directory: ${{ github.workspace }}/publish | |
| if: matrix.archive_type == 'tar' | |
| - name: Create zip archive | |
| run: Compress-Archive -Path * -DestinationPath ${{ github.workspace }}\artifacts\stack_${{ needs.version.outputs.version }}_${{ matrix.artifact-name }}.zip | |
| working-directory: ${{ github.workspace }}/publish | |
| if: matrix.archive_type == 'zip' | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| overwrite: true | |
| name: ${{ matrix.artifact-name }} | |
| path: ${{ github.workspace }}/artifacts/* | |
| pr_complete: | |
| name: PR checks complete | |
| runs-on: ubuntu-latest | |
| needs: [publish] | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - run: echo "PR required checks complete" | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: [version, publish] | |
| if: github.ref_type == 'tag' && github.event_name == 'push' | |
| permissions: | |
| contents: write | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Get all tags | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ${{ github.workspace }}/artifacts | |
| - name: List artifacts | |
| run: ls -lR ${{ github.workspace }}/artifacts | |
| - name: Release | |
| uses: softprops/action-gh-release@v2.3.2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| draft: false | |
| prerelease: false | |
| files: | | |
| ${{ github.workspace }}/artifacts/**/*.zip | |
| ${{ github.workspace }}/artifacts/**/*.tar.gz |