|
| 1 | +name: Build and release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + - 'cabal-install-*' |
| 8 | + pull_request: |
| 9 | + types: [opened, synchronize, reopened, labeled] |
| 10 | + branches: |
| 11 | + - master |
| 12 | + schedule: |
| 13 | + - cron: '0 0 * * *' |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +permissions: |
| 17 | + pull-requests: read |
| 18 | + |
| 19 | +env: |
| 20 | + BUILD_LABEL: "run release build" |
| 21 | + |
| 22 | +jobs: |
| 23 | + check-pr-labels: |
| 24 | + name: check PR labels |
| 25 | + runs-on: ubuntu-latest |
| 26 | + outputs: |
| 27 | + run_release_workflow: ${{ steps.gen_output.outputs.run_release_workflow }} |
| 28 | + steps: |
| 29 | + - id: gen_output |
| 30 | + run: | |
| 31 | + if [ "${{ github.event.action }}" == 'labeled' ] ; then |
| 32 | + if [ ${{ github.event.label.name == '${{ env.BUILD_LABEL }}' }} ] ; then |
| 33 | + echo run_release_workflow="yes" >> "$GITHUB_OUTPUT" |
| 34 | + else |
| 35 | + echo run_release_workflow="no" >> "$GITHUB_OUTPUT" |
| 36 | + fi |
| 37 | + elif [ "${{ github.event_name }}" = 'pull_request' ] ; then |
| 38 | + 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) |
| 39 | + echo "${run_it}" |
| 40 | + echo run_release_workflow="${run_it}" >> "$GITHUB_OUTPUT" |
| 41 | + else |
| 42 | + echo run_release_workflow="yes" >> "$GITHUB_OUTPUT" |
| 43 | + fi |
| 44 | + shell: bash |
| 45 | + env: |
| 46 | + GH_TOKEN: ${{ github.token }} |
| 47 | + |
| 48 | + release-workflow: |
| 49 | + needs: ["check-pr-labels"] |
| 50 | + if: ${{ needs.check-pr-labels.outputs.run_release_workflow == 'yes' }} |
| 51 | + uses: ./.github/workflows/reusable-release.yml |
| 52 | + with: |
| 53 | + branches: '["${{ github.ref }}"]' |
| 54 | + |
| 55 | + release: |
| 56 | + name: release |
| 57 | + needs: [ "release-workflow" ] |
| 58 | + runs-on: ubuntu-latest |
| 59 | + if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} |
| 60 | + steps: |
| 61 | + - name: Checkout code |
| 62 | + uses: actions/checkout@v4 |
| 63 | + |
| 64 | + - name: Download artifacts |
| 65 | + uses: actions/download-artifact@v4 |
| 66 | + with: |
| 67 | + pattern: artifacts-* |
| 68 | + merge-multiple: true |
| 69 | + path: ./out |
| 70 | + |
| 71 | + - name: Install requirements |
| 72 | + run: | |
| 73 | + sudo apt-get update && sudo apt-get install -y tar xz-utils |
| 74 | + shell: bash |
| 75 | + |
| 76 | + - name: build sdists |
| 77 | + run: | |
| 78 | + cabal sdist -o out all |
| 79 | + shell: bash |
| 80 | + |
| 81 | + - name: Release |
| 82 | + uses: softprops/action-gh-release@v1 |
| 83 | + with: |
| 84 | + draft: true |
| 85 | + files: | |
| 86 | + ./out/* |
| 87 | +
|
0 commit comments