Test #13
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: Test and Release | |
| on: | |
| pull_request: | |
| branches: | |
| - 'main' | |
| push: | |
| branches: | |
| - 'main' | |
| tags: | |
| - 'v*' | |
| - '!vlatest' | |
| workflow_dispatch: | |
| inputs: | |
| target: | |
| description: 'Target platform' | |
| required: true | |
| default: 'x86_64-apple-darwin' | |
| type: choice | |
| options: | |
| - 'x86_64-apple-darwin' | |
| - 'x86_64-unknown-linux-gnu' | |
| - 'x86_64-unknown-linux-musl' | |
| - 'x86_64-unknown-netbsd' | |
| - 'x86_64-unknown-freebsd' | |
| - 'x86_64-pc-windows-msvc' | |
| - 'x86_64-pc-windows-gnu' | |
| - 'aarch64-apple-darwin' | |
| - 'aarch64-unknown-linux-musl' | |
| - 'aarch64-unknown-linux-gnu' | |
| - 'aarch64-unknown-freebsd' | |
| - 'aarch64-pc-windows-msvc' | |
| slim: | |
| description: 'Enable slim mode' | |
| required: true | |
| default: false | |
| type: boolean | |
| use-cross: | |
| description: 'Enable cross-compilation' | |
| required: true | |
| default: false | |
| type: boolean | |
| version: | |
| description: 'The version of the pact cli to release as' | |
| default: 'latest' | |
| force_release: | |
| description: 'force release for target from branch other than main' | |
| required: true | |
| default: false | |
| type: boolean | |
| os: | |
| description: 'Operating system' | |
| required: true | |
| default: 'macos-14' | |
| type: choice | |
| options: ['ubuntu-latest', 'macos-12', 'macos-14', 'windows-latest'] | |
| jobs: | |
| version: | |
| name: "🧮 Compute the version" | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get_next_version.outputs.version }} | |
| hasNextVersion: ${{ steps.get_next_version.outputs.hasNextVersion }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| lfs: true | |
| fetch-depth: 0 | |
| - name: Get next version | |
| id: get_next_version | |
| uses: thenativeweb/get-next-version@main | |
| - name: print | |
| run: | | |
| echo "version: ${{ steps.get_next_version.outputs.version }}" | |
| echo "has_next_version: ${{ steps.get_next_version.outputs.hasNextVersion }}" | |
| changelog: | |
| needs: | |
| - version | |
| name: ✍️ Generate changelog | |
| runs-on: ubuntu-latest | |
| outputs: | |
| content: ${{steps.git-cliff.outputs.content}} | |
| release_body: ${{ steps.git-cliff-changes.outputs.content }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| lfs: true | |
| fetch-depth: 0 | |
| - name: Generate a changelog | |
| uses: orhun/git-cliff-action@v4 | |
| id: git-cliff | |
| with: | |
| config: cliff.toml | |
| args: --verbose | |
| env: | |
| OUTPUT: CHANGELOG.md | |
| - name: Print the changelog | |
| run: echo "${{ steps.git-cliff.outputs.content }}" | |
| - name: Generate a changelog | |
| uses: orhun/git-cliff-action@v4 | |
| id: git-cliff-changes | |
| with: | |
| config: cliff.toml | |
| args: -vv --latest --strip header | |
| env: | |
| OUTPUT: CHANGES.md | |
| - name: Print the changelog | |
| run: echo "${{ steps.git-cliff-changes.outputs.content }}" | |
| build-single: | |
| needs: [version, changelog] | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| uses: ./.github/workflows/reusable-build.yml | |
| with: | |
| target: ${{ github.event.inputs.target }} | |
| os: ${{ github.event.inputs.os }} | |
| use-cross: ${{ github.event.inputs.use-cross == 'true'}} | |
| slim: ${{ github.event.inputs.slim == 'true' }} | |
| version: ${{ needs.version.outputs.version }} | |
| name: '🛠️ Build binaries' | |
| permissions: | |
| contents: write | |
| build: | |
| needs: [version, changelog] | |
| if: ${{ github.event_name != 'workflow_dispatch' }} | |
| name: '🛠️ Build binaries' | |
| uses: ./.github/workflows/reusable-build.yml | |
| with: | |
| target: ${{ matrix.job.target }} | |
| os: ${{ matrix.job.os }} | |
| use-cross: ${{ matrix.job.use-cross }} | |
| slim: false | |
| version: ${{ needs.version.outputs.version }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| job: | |
| - { target: x86_64-apple-darwin, os: macos-14, use-cross: false } | |
| - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, use-cross: true } | |
| - { target: x86_64-unknown-linux-musl, os: ubuntu-latest, use-cross: true } | |
| - { target: x86_64-unknown-netbsd, os: ubuntu-latest, use-cross: true } | |
| - { target: x86_64-unknown-freebsd, os: ubuntu-latest, use-cross: true } | |
| - { target: x86_64-pc-windows-msvc, os: windows-latest, use-cross: false } | |
| - { target: x86_64-pc-windows-gnu, os: windows-latest, use-cross: false } | |
| - { target: aarch64-apple-darwin, os: macos-14, use-cross: false } | |
| - { target: aarch64-unknown-linux-musl, os: ubuntu-latest, use-cross: true } | |
| - { target: aarch64-unknown-linux-gnu, os: ubuntu-latest, use-cross: true } | |
| - { target: aarch64-unknown-freebsd, os: ubuntu-latest, use-cross: true } | |
| - { target: aarch64-pc-windows-msvc, os: windows-latest, use-cross: false } | |
| release: | |
| needs: ["build", changelog, version ] | |
| name: '📦 Github release' | |
| if: ${{ startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' }} | |
| permissions: | |
| contents: write | |
| uses: ./.github/workflows/reusable-release.yml | |
| with: | |
| version: ${{ needs.version.outputs.version }} | |
| release_notes: ${{ needs.changelog.outputs.release_body }} | |
| release-single: | |
| needs: ["build-single", changelog, version] | |
| name: '📦 Github release - single' | |
| if: ${{ inputs.force_release == true }} | |
| permissions: | |
| contents: write | |
| uses: ./.github/workflows/reusable-release.yml | |
| with: | |
| version: ${{ needs.version.outputs.version }} | |
| release_notes: ${{ needs.changelog.outputs.release_body }} | |
| force_release: ${{ github.event.inputs.force_release == 'true' }} |