flowctl #12
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: flowctl | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| rel_version: | |
| description: 'Release version (examples: 1.9.0-rc.1, 1.9.1)' | |
| required: true | |
| type: string | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: ['ubuntu-latest', 'windows-latest', 'macos-latest'] | |
| os_arch: [x64, arm, arm64] | |
| include: | |
| - os: ubuntu-latest | |
| kind: linux | |
| title: linux | |
| - os: windows-latest | |
| kind: win | |
| title: windows | |
| - os: macos-latest | |
| kind: osx | |
| title: osx | |
| exclude: | |
| - os: windows-latest | |
| os_arch: arm | |
| - os: macOS-latest | |
| os_arch: arm | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| ARCHIVE_OUTDIR: dist/archives | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 0 #fetch-depth is needed for GitVersion | |
| #Install and calculate the new version with GitVersion | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v0.9.7 | |
| with: | |
| versionSpec: 5.x | |
| - name: Determine Version | |
| uses: gittools/actions/gitversion/execute@v0.9.7 | |
| id: gitversion # step id used as reference for output values | |
| - name: Display GitVersion outputs | |
| run: | | |
| echo "Version: ${{ inputs.rel_version }}" | |
| #Build/pack the project | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v3.2.0 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Prep packages | |
| run: dotnet nuget add source --username ziagham --password ${{ secrets.GH_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{github.repository_owner}}/index.json" | |
| - name: Publish | |
| shell: bash | |
| run: | | |
| release_name="flowctl-${{ matrix.title }}-${{ matrix.os_arch }}" | |
| dotnet publish src/FlowCtl/FlowCtl.csproj /property:PublishSingleFile=true /property:PublishReadyToRun=true --runtime '${{ matrix.kind }}-${{ matrix.os_arch }}' -c Release --self-contained true /property:Version='${{ inputs.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 | |
| cd "${{github.workspace}}" | |
| - name: Upload bineries | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: flowctl-${{ matrix.title }}-${{ matrix.os_arch }} | |
| path: "${{github.workspace}}/dist" | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.ref == 'refs/heads/master' # only run job if on the master branch | |
| env: | |
| ARTIFACT_DIR: ./release | |
| steps: | |
| #Release and add artifacts to the release | |
| - name: Download nuget package artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: flowctl-* | |
| path: ${{ env.ARTIFACT_DIR }} | |
| merge-multiple: true | |
| - name: generate checksum files | |
| run: cd ${ARTIFACT_DIR} && for i in *; do sha256sum -b $i > "$i.sha256"; done && cd - | |
| - name: Create Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: v${{ inputs.rel_version }} | |
| name: FlowCtl v${{ inputs.rel_version }} | |
| body: "This is the v${{ inputs.rel_version }} release of FlowCtl" | |
| artifacts: "**/*.*" | |
| token: ${{ secrets.GH_TOKEN }} | |
| - name: Create Branch | |
| uses: peterjgrainger/action-create-branch@v2.2.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
| with: | |
| branch: 'release-${{ inputs.rel_version }}' | |
| sha: '${{ github.event.pull_request.head.sha }}' |