Create release #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Copyright 2024 Copyright 2022 Aiven Oy and | |
# bigquery-connector-for-apache-kafka project contributors | |
# | |
# This software contains code derived from the Confluent BigQuery | |
# Kafka Connector, Copyright Confluent, Inc, which in turn | |
# contains code derived from the WePay BigQuery Kafka Connector, | |
# Copyright WePay, Inc. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, | |
# software distributed under the License is distributed on an | |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
# KIND, either express or implied. See the License for the | |
# specific language governing permissions and limitations | |
# under the License. | |
# | |
name: Create release | |
on: | |
workflow_dispatch: | |
inputs: | |
commit_hash: | |
description: "Hash of 'Release version x.y.z' commit" | |
required: true | |
permissions: | |
contents: write | |
pull-requests: write | |
issues: write | |
jobs: | |
build: | |
name: Create Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.inputs.commit_hash }} | |
- name: Check commit title and extract version | |
run: | | |
export commit_title=$(git log --pretty=format:%s -1 ${{ github.event.inputs.commit_hash }}) | |
echo "Commit title: $commit_title" | |
if [[ $commit_title =~ ^Release\ version\ [0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc[0-9]+))?$ ]]; then | |
echo "Valid commit title" | |
else | |
echo "Invalid commit title" | |
exit 1 | |
fi | |
export version=$(echo ${commit_title} | sed s/^Release\ version\ //g) | |
echo "Will use version ${version}" | |
echo "version=${version}" >> $GITHUB_ENV | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'adopt' | |
java-version: 8 | |
cache: maven | |
- name: Build | |
run: | | |
mvn install -DskipTests | |
mvn -f kcbq-connector clean package assembly:single@release-artifacts -DskipTests | |
export tar_file=$(ls ./kcbq-connector/target/ | grep tar) | |
export zip_file=$(ls ./kcbq-connector/target/ | grep zip) | |
echo tar_file=${tar_file} >> $GITHUB_ENV | |
echo zip_file=${zip_file} >> $GITHUB_ENV | |
echo tar_path=`realpath ./kcbq-connector/target/${tar_file}` >> $GITHUB_ENV | |
echo zip_path=`realpath ./kcbq-connector/target/${zip_file}` >> $GITHUB_ENV | |
- name: Create tag | |
run: | | |
git config --local user.name "GitHub Action" | |
git config --local user.email "action@github.com" | |
git tag -a "v${{ env.version }}" -m "Release version ${{ env.version }}" | |
git push origin "v${{ env.version }}" | |
- name: Create release draft | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{ env.version }}" | |
release_name: "v${{ env.version }}" | |
commitish: ${{ github.event.inputs.commit_hash }} | |
body: | | |
*Fill in* | |
draft: true | |
prerelease: false | |
- name: Upload tar | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ env.tar_path }} | |
asset_name: ${{ env.tar_file }} | |
asset_content_type: application/tar | |
- name: Upload zip | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ env.zip_path }} | |
asset_name: ${{ env.zip_file }} | |
asset_content_type: application/zip |