|
| 1 | +# |
| 2 | +# Copyright 2024 Copyright 2022 Aiven Oy and |
| 3 | +# bigquery-connector-for-apache-kafka project contributors |
| 4 | +# |
| 5 | +# This software contains code derived from the Confluent BigQuery |
| 6 | +# Kafka Connector, Copyright Confluent, Inc, which in turn |
| 7 | +# contains code derived from the WePay BigQuery Kafka Connector, |
| 8 | +# Copyright WePay, Inc. |
| 9 | +# |
| 10 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 11 | +# you may not use this file except in compliance with the License. |
| 12 | +# You may obtain a copy of the License at |
| 13 | +# |
| 14 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | +# |
| 16 | +# Unless required by applicable law or agreed to in writing, |
| 17 | +# software distributed under the License is distributed on an |
| 18 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 19 | +# KIND, either express or implied. See the License for the |
| 20 | +# specific language governing permissions and limitations |
| 21 | +# under the License. |
| 22 | +# |
| 23 | + |
| 24 | +name: Create release |
| 25 | + |
| 26 | +on: |
| 27 | + workflow_dispatch: |
| 28 | + inputs: |
| 29 | + commit_hash: |
| 30 | + description: "Hash of 'Release version x.y.z' commit" |
| 31 | + required: true |
| 32 | + |
| 33 | +jobs: |
| 34 | + build: |
| 35 | + name: Create Release |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + - name: Setup Java SDK |
| 39 | + |
| 40 | + with: |
| 41 | + java-version: 11 |
| 42 | + |
| 43 | + - name: Checkout code |
| 44 | + uses: actions/checkout@v2 |
| 45 | + with: |
| 46 | + ref: ${{ github.event.inputs.commit_hash }} |
| 47 | + |
| 48 | + - name: Check commit title and extract version |
| 49 | + run: | |
| 50 | + export commit_title=$(git log --pretty=format:%s -1 ${{ github.event.inputs.commit_hash }}) |
| 51 | + echo "Commit title: $commit_title" |
| 52 | + if [[ $commit_title =~ ^Release\ version\ [0-9]*\.[0-9]*\.[0-9]*$ ]]; then |
| 53 | + echo "Valid commit title" |
| 54 | + else |
| 55 | + echo "Invalid commit title" |
| 56 | + exit 1 |
| 57 | + fi |
| 58 | + export version=$(echo ${commit_title} | sed s/^Release\ version\ //g) |
| 59 | + echo "Will use version ${version}" |
| 60 | + echo "version=${version}" >> $GITHUB_ENV |
| 61 | +
|
| 62 | + - name: Build |
| 63 | + run: | |
| 64 | + mvn -f kcbq-connector clean package assembly:single@release-artifacts -DskipTests |
| 65 | +
|
| 66 | + export tar_file=$(ls ./kcbq-connector/target/ | grep tar) |
| 67 | + export zip_file=$(ls ./kcbq-connector/target/ | grep zip) |
| 68 | + echo tar_file=${tar_file} >> $GITHUB_ENV |
| 69 | + echo zip_file=${zip_file} >> $GITHUB_ENV |
| 70 | +
|
| 71 | + echo tar_path=`realpath ./kcbq-connector/target/${tar_file}` >> $GITHUB_ENV |
| 72 | + echo zip_path=`realpath ./kcbq-connector/target/${zip_file}` >> $GITHUB_ENV |
| 73 | +
|
| 74 | + - name: Create tag |
| 75 | + run: | |
| 76 | + git config --local user.name "GitHub Action" |
| 77 | + git config --local user.email "[email protected]" |
| 78 | + git tag -a "v${{ env.version }}" -m "Release version ${{ env.version }}" |
| 79 | + git push origin "v${{ env.version }}" |
| 80 | +
|
| 81 | + - name: Create release draft |
| 82 | + id: create_release |
| 83 | + uses: actions/create-release@v1 |
| 84 | + env: |
| 85 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + with: |
| 87 | + tag_name: "v${{ env.version }}" |
| 88 | + release_name: "v${{ env.version }}" |
| 89 | + commitish: ${{ github.event.inputs.commit_hash }} |
| 90 | + body: | |
| 91 | + *Fill in* |
| 92 | + draft: true |
| 93 | + prerelease: false |
| 94 | + |
| 95 | + - name: Upload tar |
| 96 | + uses: actions/upload-release-asset@v1 |
| 97 | + env: |
| 98 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + with: |
| 100 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 101 | + asset_path: ${{ env.tar_path }} |
| 102 | + asset_name: ${{ env.tar_file }} |
| 103 | + asset_content_type: application/tar |
| 104 | + |
| 105 | + - name: Upload zip |
| 106 | + uses: actions/upload-release-asset@v1 |
| 107 | + env: |
| 108 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 109 | + with: |
| 110 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 111 | + asset_path: ${{ env.zip_path }} |
| 112 | + asset_name: ${{ env.zip_file }} |
| 113 | + asset_content_type: application/zip |
0 commit comments