Build and release #32
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 and release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| - 'cabal-install-*' | |
| pull_request: | |
| types: [opened, synchronize, reopened, labeled] | |
| branches: | |
| - master | |
| schedule: | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| pull-requests: read | |
| contents: write | |
| env: | |
| BUILD_LABEL: "run release build" | |
| jobs: | |
| check-pr-labels: | |
| name: check PR labels | |
| runs-on: ubuntu-latest | |
| outputs: | |
| run_release_workflow: ${{ steps.gen_output.outputs.run_release_workflow }} | |
| steps: | |
| - id: gen_output | |
| run: | | |
| if [ "${{ github.event.action }}" == 'labeled' ] ; then | |
| if [ "${{ github.event.label.name }}" == "${{ env.BUILD_LABEL }}" ] ; then | |
| echo run_release_workflow="yes" >> "$GITHUB_OUTPUT" | |
| else | |
| echo run_release_workflow="no" >> "$GITHUB_OUTPUT" | |
| fi | |
| elif [ "${{ github.event_name }}" = 'pull_request' ] ; then | |
| run_it=$(if gh api --jq '.labels.[].name' /repos/${{ github.repository }}/pulls/${{ github.event.number }} | grep --quiet '^${{ env.BUILD_LABEL }}$' ; then printf "%s" "yes" ; else printf "%s" "no" ; fi) | |
| echo "${run_it}" | |
| echo run_release_workflow="${run_it}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo run_release_workflow="yes" >> "$GITHUB_OUTPUT" | |
| fi | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| release-workflow: | |
| needs: ["check-pr-labels"] | |
| if: ${{ needs.check-pr-labels.outputs.run_release_workflow == 'yes' }} | |
| uses: ./.github/workflows/reusable-release.yml | |
| with: | |
| branches: '["${{ github.ref }}"]' | |
| release: | |
| name: release | |
| needs: [ "release-workflow" ] | |
| runs-on: ubuntu-latest | |
| if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: artifacts-* | |
| merge-multiple: true | |
| path: ./out | |
| - name: Install requirements | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y tar xz-utils | |
| shell: bash | |
| # NOTE ☞: Here is where we decide what to output in a GitHub release, | |
| # so if we add a package which is meant to be released to Cabal, this | |
| # has to be changed. See issue #12179. | |
| - name: build sdists | |
| run: | | |
| cabal sdist --output-directory out/ Cabal-syntax Cabal-hooks Cabal cabal-install-solver hooks-exe cabal-install | |
| shell: bash | |
| - name: Release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| draft: true | |
| files: | | |
| ./out/* | |