github.com/prebid/prebid-server@v0.275.0/.github/workflows/release.yml (about)

     1  name: Release
     2  
     3  on:
     4    workflow_dispatch:
     5      inputs:
     6        releaseType:
     7          type: choice
     8          options:
     9            - minor
    10            - patch
    11          default: minor
    12          required: true
    13          description: 'minor: v0.X.0, patch: v0.0.X'
    14        debug:
    15          type: boolean
    16          default: true
    17          description: 'executes the workflow in debug mode (skip the publishing tag, docker image and release steps)'
    18  
    19  jobs:
    20    check-permission:
    21      name: Check permission
    22      if: contains(github.ref, 'refs/heads/master')
    23      runs-on: ubuntu-latest
    24      permissions:
    25        contents: read
    26      steps:
    27        - name: Check user permission
    28          uses: actions-cool/check-user-permission@v2.2.0
    29          id: check
    30          with:
    31            require: 'write'
    32      outputs:
    33        hasWritePermission: ${{ steps.check.outputs.require-result }}
    34  
    35    build-master:
    36      name: Build master
    37      needs: check-permission
    38      if: contains(needs.check-permission.outputs.hasWritePermission, 'true')
    39      runs-on: ubuntu-latest
    40      steps:
    41        - name: Checkout
    42          uses: actions/checkout@master
    43          with:
    44            fetch-depth: 0
    45            repository: ${{ github.repository }}
    46            ref: master
    47        - name: Build and validate
    48          run: |
    49            ./validate.sh
    50  
    51    publish-tag:
    52      name: Publish tag
    53      needs: build-master
    54      if: contains(needs.check-permission.outputs.hasWritePermission, 'true')
    55      permissions:
    56        contents: write
    57      runs-on: ubuntu-latest
    58      steps:
    59        - name: Checkout Prebid Server
    60          uses: actions/checkout@v3
    61          with:
    62            fetch-depth: 0
    63        - name: Create & publish tag
    64          id: release
    65          run: |
    66            currentTag=$(git describe --abbrev=0 --tags)
    67            echo "Current release tag ${currentTag}"
    68  
    69            echo ${currentTag} | grep -q "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$"
    70            if [ $? -ne 0 ]; then
    71              echo "Current tag format won't let us compute the new tag name. Required format v[0-9]\+\.[0-9]\+\.[0-9]\+"
    72              exit 1
    73            fi
    74  
    75            if [[ "${currentTag:0:1}" != "v" ]]; then
    76              currentTag="v${currentTag}"
    77            fi
    78  
    79            nextTag=''
    80            releaseType=${{ inputs.releaseType }}
    81            if [ $releaseType == "minor" ]; then
    82              # increment minor version and reset patch version
    83              nextTag=$(echo "${currentTag}" | awk -F. '{OFS="."; $2+=1; $3=0; print $0}')
    84            else
    85              # increment patch version
    86              nextTag=$(echo "${currentTag}" | awk -F. '{OFS="."; $3+=1; print $0}')
    87            fi
    88  
    89            if [ ${{ inputs.debug }} == 'true' ]; then
    90              echo "running workflow in debug mode, next ${releaseType} tag: ${nextTag}"
    91            else
    92              git tag $nextTag
    93              git push origin $nextTag
    94              echo "tag=${nextTag}" >> $GITHUB_OUTPUT
    95            fi
    96      outputs:
    97        releaseTag: ${{ steps.release.outputs.tag }}
    98  
    99    publish-docker-image:
   100      name: Publish docker image
   101      needs: publish-tag
   102      if: contains(inputs.debug, 'false')
   103      runs-on: ubuntu-latest
   104      steps:
   105        - name: Checkout Prebid Server
   106          uses: actions/checkout@v3
   107          with:
   108            fetch-depth: 0
   109        - name: Build image
   110          run: |
   111            docker build -t docker.io/prebid/prebid-server:${{ needs.publish-tag.outputs.releaseTag }} .
   112        - name: Login to docker Hub
   113          if: contains(inputs.debug, 'false')
   114          uses: docker/login-action@v2.1.0
   115          with:
   116            username: ${{ secrets.DOCKERHUB_USER }}
   117            password: ${{ secrets.DOCKERHUB_PASSWORD }}
   118        - name: Publish to docker Hub
   119          run: |
   120            docker push docker.io/prebid/prebid-server:${{ needs.publish-tag.outputs.releaseTag }}
   121  
   122    publish-release:
   123      name: Publish release
   124      needs: [publish-tag, publish-docker-image] 
   125      if: contains(inputs.debug, 'false')
   126      permissions:
   127        contents: write
   128      runs-on: ubuntu-latest
   129      steps:
   130        - name: Checkout Prebid Server
   131          uses: actions/checkout@v3
   132          with:
   133            fetch-depth: 0
   134        - name: Create & publish release
   135          uses: release-drafter/release-drafter@v5.22.0
   136          with:
   137            name: ${{ needs.publish-tag.outputs.releaseTag }}
   138            tag: ${{ needs.publish-tag.outputs.releaseTag }}
   139            version: ${{ needs.publish-tag.outputs.releaseTag }}
   140            publish: true
   141          env:
   142            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}