Repository navigation
Release #14
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: | |
| rel_version: | |
| description: 'Release version (examples: 1.9.0-rc.1, 1.9.1)' | |
| required: true | |
| type: string | |
| prerelease: | |
| description: 'Mark this as a pre-release' | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Validate version format | |
| env: | |
| REL_VERSION: ${{ inputs.rel_version }} | |
| run: | | |
| if ! echo "${REL_VERSION}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then | |
| echo "Invalid version format: ${REL_VERSION}" | |
| exit 1 | |
| fi | |
| build: | |
| needs: validate | |
| permissions: | |
| contents: read | |
| packages: read | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| kind: linux | |
| title: linux | |
| os_arch: x64 | |
| - os: ubuntu-latest | |
| kind: linux | |
| title: linux | |
| os_arch: arm64 | |
| - os: windows-latest | |
| kind: win | |
| title: windows | |
| os_arch: x64 | |
| - os: windows-latest | |
| kind: win | |
| title: windows | |
| os_arch: arm64 | |
| - os: macos-latest | |
| kind: osx | |
| title: osx | |
| os_arch: x64 | |
| - os: macos-latest | |
| kind: osx | |
| title: osx | |
| os_arch: arm64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Publish | |
| shell: bash | |
| env: | |
| REL_VERSION: ${{ inputs.rel_version }} | |
| run: | | |
| release_name="synctl-${{ matrix.title }}-${{ matrix.os_arch }}" | |
| dotnet publish src/SynentraCtl/SynentraCtl.csproj \ | |
| /property:PublishSingleFile=true \ | |
| /property:PublishReadyToRun=true \ | |
| --runtime "${{ matrix.kind }}-${{ matrix.os_arch }}" \ | |
| -c Release \ | |
| --self-contained true \ | |
| /property:Version="${REL_VERSION}" \ | |
| -o "${{ github.workspace }}/${release_name}" | |
| mkdir -p "${{ github.workspace }}/dist" | |
| cd "${{ github.workspace }}/${release_name}" | |
| if [ "${{ matrix.kind }}" == "win" ]; then | |
| 7z a -tzip "${{ github.workspace }}/dist/${release_name}.zip" * | |
| else | |
| tar czvf "${{ github.workspace }}/dist/${release_name}.tar.gz" * | |
| fi | |
| - name: Upload binaries | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: synctl-${{ matrix.title }}-${{ matrix.os_arch }} | |
| path: | | |
| ${{ github.workspace }}/dist/*.zip | |
| ${{ github.workspace }}/dist/*.tar.gz | |
| if-no-files-found: error | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: write | |
| env: | |
| ARTIFACT_DIR: ./release | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: synctl-* | |
| path: ${{ env.ARTIFACT_DIR }} | |
| merge-multiple: true | |
| - name: Inspect downloaded artifacts | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| echo "Contents of ${{ env.ARTIFACT_DIR }}:" | |
| find "${{ env.ARTIFACT_DIR }}" -maxdepth 2 -type f | sort | |
| - name: Generate checksum files | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| cd "${{ env.ARTIFACT_DIR }}" | |
| mapfile -t files < <(find . -type f \( -name '*.zip' -o -name '*.tar.gz' \) | sort) | |
| if [ ${#files[@]} -eq 0 ]; then | |
| echo "No release archives were downloaded into ${PWD}" | |
| find . -maxdepth 3 -type f | sort || true | |
| exit 1 | |
| fi | |
| for i in "${files[@]}"; do | |
| sha256sum -b "$i" > "$i.sha256" | |
| done | |
| - name: Create Release | |
| uses: ncipollo/release-action@40bb172bd05f266cf9ba4ff965cb61e9ee5f6d01 # v1.9.0 | |
| with: | |
| tag: v${{ inputs.rel_version }} | |
| name: SynCtl v${{ inputs.rel_version }} | |
| generateReleaseNotes: true | |
| prerelease: ${{ inputs.prerelease }} | |
| artifacts: "${{ env.ARTIFACT_DIR }}/*" | |
| token: ${{ secrets.GITHUB_TOKEN }} |