github.com/prebid/prebid-server/v2@v2.18.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 - major 10 - minor 11 - patch 12 default: minor 13 required: true 14 description: 'major: vX.0.0, minor: v0.X.0, patch: v0.0.X' 15 debug: 16 type: boolean 17 default: true 18 description: 'executes the workflow in debug mode (skip the publishing tag, docker image and release steps)' 19 20 jobs: 21 check-permission: 22 name: Check permission 23 if: contains(github.ref, 'refs/heads/master') 24 runs-on: ubuntu-latest 25 permissions: 26 contents: read 27 steps: 28 - name: Checkout 29 uses: actions/checkout@v4 30 with: 31 fetch-depth: 0 32 repository: ${{ github.repository }} 33 ref: master 34 - name: Check user permission 35 uses: actions/github-script@v7 36 id: check 37 with: 38 github-token: ${{ secrets.GITHUB_TOKEN }} 39 result-encoding: string 40 script: | 41 const utils = require('./.github/workflows/helpers/pull-request-utils.js') 42 const helper = utils.userHelper({github, context, user: '${{ github.actor }}'}) 43 const hasPermission = await helper.hasWritePermissions() 44 return hasPermission 45 outputs: 46 hasWritePermission: ${{ steps.check.outputs.result }} 47 48 build-master: 49 name: Build master 50 needs: check-permission 51 if: contains(needs.check-permission.outputs.hasWritePermission, 'true') 52 runs-on: ubuntu-latest 53 steps: 54 - name: Checkout 55 uses: actions/checkout@v4 56 with: 57 fetch-depth: 0 58 repository: ${{ github.repository }} 59 ref: master 60 - name: Build and validate 61 run: | 62 ./validate.sh 63 64 publish-tag: 65 name: Publish tag 66 needs: build-master 67 permissions: 68 contents: write 69 runs-on: ubuntu-latest 70 steps: 71 - name: Checkout Prebid Server 72 uses: actions/checkout@v4 73 with: 74 fetch-depth: 0 75 - name: Create & publish tag 76 id: release 77 run: | 78 currentTag=$(git describe --abbrev=0 --tags) 79 echo "Current release tag ${currentTag}" 80 81 echo ${currentTag} | grep -q "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$" 82 if [ $? -ne 0 ]; then 83 echo "Current tag format won't let us compute the new tag name. Required format v[0-9]\+\.[0-9]\+\.[0-9]\+" 84 exit 1 85 fi 86 87 if [[ "${currentTag:0:1}" != "v" ]]; then 88 currentTag="v${currentTag}" 89 fi 90 91 nextTag='' 92 releaseType=${{ inputs.releaseType }} 93 if [ $releaseType == "major" ]; then 94 # PBS-GO skipped the v1.0.0 major release - https://github.com/prebid/prebid-server/issues/3068 95 # If the current tag is v0.x.x, the script sets the next release tag to v2.0.0 96 # Otherwise, the script increments the major version by 1 and sets the minor and patch versions to zero 97 # For example, v2.x.x will be incremented to v3.0.0 98 major=$(echo "${currentTag}" | awk -F. '{gsub(/^v/, "", $1); if($1 == 0) $1=2; else $1+=1; print $1}') 99 nextTag="v${major}.0.0" 100 elif [ $releaseType == "minor" ]; then 101 # Increment minor version and reset patch version 102 nextTag=$(echo "${currentTag}" | awk -F. '{OFS="."; $2+=1; $3=0; print $0}') 103 else 104 # Increment patch version 105 nextTag=$(echo "${currentTag}" | awk -F. '{OFS="."; $3+=1; print $0}') 106 fi 107 108 if [ ${{ inputs.debug }} == 'true' ]; then 109 echo "running workflow in debug mode, next ${releaseType} tag: ${nextTag}" 110 else 111 git tag $nextTag 112 git push origin $nextTag 113 echo "tag=${nextTag}" >> $GITHUB_OUTPUT 114 fi 115 outputs: 116 releaseTag: ${{ steps.release.outputs.tag }} 117 118 publish-docker-image: 119 name: Publish docker image 120 needs: publish-tag 121 if: contains(inputs.debug, 'false') 122 runs-on: ubuntu-latest 123 steps: 124 - name: Checkout Prebid Server 125 uses: actions/checkout@v4 126 with: 127 fetch-depth: 0 128 - name: Build image 129 run: | 130 docker build -t docker.io/prebid/prebid-server:${{ needs.publish-tag.outputs.releaseTag }} . 131 - name: Login to docker Hub 132 if: contains(inputs.debug, 'false') 133 uses: docker/login-action@v2.1.0 134 with: 135 username: ${{ secrets.DOCKERHUB_USER }} 136 password: ${{ secrets.DOCKERHUB_PASSWORD }} 137 - name: Publish to docker Hub 138 run: | 139 docker push docker.io/prebid/prebid-server:${{ needs.publish-tag.outputs.releaseTag }} 140 141 publish-release: 142 name: Publish release 143 needs: [publish-tag, publish-docker-image] 144 if: contains(inputs.debug, 'false') 145 permissions: 146 contents: write 147 runs-on: ubuntu-latest 148 steps: 149 - name: Checkout Prebid Server 150 uses: actions/checkout@v3 151 with: 152 fetch-depth: 0 153 - name: Create & publish release 154 uses: release-drafter/release-drafter@v5.22.0 155 with: 156 name: ${{ needs.publish-tag.outputs.releaseTag }} 157 tag: ${{ needs.publish-tag.outputs.releaseTag }} 158 version: ${{ needs.publish-tag.outputs.releaseTag }} 159 publish: true 160 env: 161 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}