|
| 1 | +name: release |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + pull_request: |
| 7 | + types: |
| 8 | + - labeled |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + if: github.event.action != 'labeled' |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + |
| 16 | + |
| 17 | + # Bump version on merging Pull Requests with specific labels. |
| 18 | + # (bump:major,bump:minor,bump:patch) |
| 19 | + - id: bumpr |
| 20 | + if: "!startsWith(github.ref, 'refs/tags/')" |
| 21 | + uses: haya14busa/action-bumpr@v1 |
| 22 | + |
| 23 | + # Update corresponding major and minor tag. |
| 24 | + # e.g. Update v1 and v1.2 when releasing v1.2.3 |
| 25 | + - uses: haya14busa/[email protected] |
| 26 | + if: "!steps.bumpr.outputs.skip" |
| 27 | + with: |
| 28 | + tag: ${{ steps.bumpr.outputs.next_version }} |
| 29 | + |
| 30 | + # Get tag name. |
| 31 | + - id: tag |
| 32 | + uses: haya14busa/action-cond@v1 |
| 33 | + with: |
| 34 | + cond: "${{ startsWith(github.ref, 'refs/tags/') }}" |
| 35 | + if_true: ${{ github.ref }} |
| 36 | + if_false: ${{ steps.bumpr.outputs.next_version }} |
| 37 | + |
| 38 | + # Create release. |
| 39 | + - uses: actions/create-release@v1 |
| 40 | + if: "steps.tag.outputs.value != ''" |
| 41 | + env: |
| 42 | + # This token is provided by Actions, you do not need to create your own token |
| 43 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + with: |
| 45 | + tag_name: ${{ steps.tag.outputs.value }} |
| 46 | + release_name: Release ${{ steps.tag.outputs.value }} |
| 47 | + body: ${{ steps.bumpr.outputs.message }} |
| 48 | + draft: false |
| 49 | + prerelease: false |
| 50 | + |
| 51 | + publish: |
| 52 | + needs: release |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v2 |
| 56 | + |
| 57 | + - uses: actions-ecosystem/action-get-latest-tag@v1 |
| 58 | + id: get-latest-tag |
| 59 | + with: |
| 60 | + semver_only: true |
| 61 | + |
| 62 | + - name: Set up QEMU |
| 63 | + |
| 64 | + |
| 65 | + - name: Set up Docker Buildx |
| 66 | + |
| 67 | + |
| 68 | + - name: Login to DockerHub |
| 69 | + |
| 70 | + with: |
| 71 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 72 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 73 | + |
| 74 | + - name: Build and push |
| 75 | + id: docker_build |
| 76 | + |
| 77 | + with: |
| 78 | + push: true |
| 79 | + tags: | |
| 80 | + asaasdev/codenarc:${{ steps.get-latest-tag.outputs.tag }} |
| 81 | + asaasdev/codenarc:latest |
| 82 | + |
| 83 | + - name: Image digest |
| 84 | + run: echo ${{ steps.docker_build.outputs.digest }} |
| 85 | + |
| 86 | + release-check: |
| 87 | + if: github.event.action == 'labeled' |
| 88 | + runs-on: ubuntu-latest |
| 89 | + steps: |
| 90 | + |
| 91 | + |
| 92 | + - name: Post bumpr status comment |
| 93 | + uses: haya14busa/action-bumpr@v1 |
0 commit comments