Skip to content

Commit 91cfa83

Browse files
authored
Add actions for creating releases (#14)
1 parent 5fe27f5 commit 91cfa83

File tree

6 files changed

+303
-0
lines changed

6 files changed

+303
-0
lines changed

.github/workflows/create_release.yml

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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+
uses: actions/[email protected]
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
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
# The workflow to create PRs with release commits.
25+
name: Create release PR
26+
on:
27+
workflow_dispatch:
28+
inputs:
29+
release_version:
30+
description: "Release version '0.1.2' (without 'v')"
31+
required: true
32+
snapshot_version:
33+
description: "Snapshot version '0.2.0-SNAPSHOT' (without 'v')"
34+
required: true
35+
36+
jobs:
37+
create_release_pr:
38+
name: Create release PR (job)
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Check versions
42+
run: |
43+
echo "Checking release version..."
44+
if echo ${{ github.event.inputs.release_version }} | grep --invert-match '^[0-9]\+\.[0-9]\+\.[0-9]\+$' > /dev/null; then
45+
echo "Release version is invalid"
46+
exit 1
47+
fi
48+
49+
echo "Checking snapshot version..."
50+
if echo ${{ github.event.inputs.snapshot_version }} | grep --invert-match '^[0-9]\+\.[0-9]\+\.[0-9]\+-SNAPSHOT$' > /dev/null; then
51+
echo "Snapshot version is invalid"
52+
exit 1
53+
fi
54+
55+
- name: Checkout master
56+
uses: actions/checkout@v2
57+
with:
58+
ref: master
59+
fetch-depth: 0
60+
61+
- name: Create release commits
62+
run: |
63+
git config --local user.name "GitHub Action"
64+
git config --local user.email "[email protected]"
65+
mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${{ github.event.inputs.release_version }}
66+
git add pom.xml kcbq-api/pom.xml kcbq-connector/pom.xml
67+
git commit -m "Release version ${{ github.event.inputs.release_version }}"
68+
mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${{ github.event.inputs.snapshot_version }}
69+
git add pom.xml kcbq-api/pom.xml kcbq-connector/pom.xml
70+
git commit -m "Bump version to ${{ github.event.inputs.snapshot_version }}"
71+
72+
- name: Create Pull Request
73+
uses: peter-evans/create-pull-request@v3
74+
with:
75+
branch: release-${{ github.event.inputs.release_version }}
76+
delete-branch: true
77+
draft: true
78+
title: Release version ${{ github.event.inputs.release_version }}
79+
body: |
80+
Proposed changelog:
81+
- *fill in*

kcbq-connector/pom.xml

+21
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,27 @@
195195
</execution>
196196
</executions>
197197
</plugin>
198+
<plugin>
199+
<groupId>org.apache.maven.plugins</groupId>
200+
<artifactId>maven-assembly-plugin</artifactId>
201+
<executions>
202+
<execution>
203+
<id>release-artifacts</id>
204+
<goals>
205+
<goal>single</goal>
206+
</goals>
207+
</execution>
208+
</executions>
209+
<configuration>
210+
<finalName>bigquery-connector-for-apache-kafka-${project.version}</finalName>
211+
<appendAssemblyId>false</appendAssemblyId>
212+
<descriptors>
213+
<descriptor>src/main/assembly/release-tar.xml</descriptor>
214+
<descriptor>src/main/assembly/release-zip.xml</descriptor>
215+
</descriptors>
216+
<tarLongFileMode>posix</tarLongFileMode>
217+
</configuration>
218+
</plugin>
198219
</plugins>
199220
</build>
200221
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!--
2+
3+
Copyright 2024 Copyright 2022 Aiven Oy and
4+
bigquery-connector-for-apache-kafka project contributors
5+
6+
This software contains code derived from the Confluent BigQuery
7+
Kafka Connector, Copyright Confluent, Inc, which in turn
8+
contains code derived from the WePay BigQuery Kafka Connector,
9+
Copyright WePay, Inc.
10+
11+
Licensed under the Apache License, Version 2.0 (the "License");
12+
you may not use this file except in compliance with the License.
13+
You may obtain a copy of the License at
14+
15+
http://www.apache.org/licenses/LICENSE-2.0
16+
17+
Unless required by applicable law or agreed to in writing,
18+
software distributed under the License is distributed on an
19+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20+
KIND, either express or implied. See the License for the
21+
specific language governing permissions and limitations
22+
under the License.
23+
24+
-->
25+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/${mdoVersion}"
26+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
27+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/${mdoVersion} https://maven.apache.org/xsd/assembly-${mdoVersion}.xsd">
28+
<id>release-tar</id>
29+
<formats>
30+
<format>tar</format>
31+
</formats>
32+
<includeBaseDirectory>false</includeBaseDirectory>
33+
<dependencySets>
34+
<dependencySet>
35+
<outputDirectory>/</outputDirectory>
36+
<useProjectArtifact>true</useProjectArtifact>
37+
<unpack>true</unpack>
38+
<scope>runtime</scope>
39+
</dependencySet>
40+
</dependencySets>
41+
</assembly>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!--
2+
3+
Copyright 2024 Copyright 2022 Aiven Oy and
4+
bigquery-connector-for-apache-kafka project contributors
5+
6+
This software contains code derived from the Confluent BigQuery
7+
Kafka Connector, Copyright Confluent, Inc, which in turn
8+
contains code derived from the WePay BigQuery Kafka Connector,
9+
Copyright WePay, Inc.
10+
11+
Licensed under the Apache License, Version 2.0 (the "License");
12+
you may not use this file except in compliance with the License.
13+
You may obtain a copy of the License at
14+
15+
http://www.apache.org/licenses/LICENSE-2.0
16+
17+
Unless required by applicable law or agreed to in writing,
18+
software distributed under the License is distributed on an
19+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20+
KIND, either express or implied. See the License for the
21+
specific language governing permissions and limitations
22+
under the License.
23+
24+
-->
25+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/${mdoVersion}"
26+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
27+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/${mdoVersion} https://maven.apache.org/xsd/assembly-${mdoVersion}.xsd">
28+
<id>release-zip</id>
29+
<formats>
30+
<format>zip</format>
31+
</formats>
32+
<includeBaseDirectory>false</includeBaseDirectory>
33+
<dependencySets>
34+
<dependencySet>
35+
<outputDirectory>/</outputDirectory>
36+
<useProjectArtifact>true</useProjectArtifact>
37+
<unpack>true</unpack>
38+
<scope>runtime</scope>
39+
</dependencySet>
40+
</dependencySets>
41+
</assembly>

pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<junit.version>5.10.2</junit.version>
5454
<mockito.version>3.2.4</mockito.version>
5555

56+
<assembly.plugin.version>3.7.0</assembly.plugin.version>
5657
<buildnumber.plugin.version>1.4</buildnumber.plugin.version>
5758
<checkstyle.plugin.version>3.3.1</checkstyle.plugin.version>
5859
<compiler.plugin.version>3.8.1</compiler.plugin.version>
@@ -388,6 +389,11 @@ under the License.
388389
<target>${java.version}</target>
389390
</configuration>
390391
</plugin>
392+
<plugin>
393+
<groupId>org.apache.maven.plugins</groupId>
394+
<artifactId>maven-assembly-plugin</artifactId>
395+
<version>${assembly.plugin.version}</version>
396+
</plugin>
391397
<plugin>
392398
<groupId>org.apache.maven.plugins</groupId>
393399
<artifactId>maven-surefire-plugin</artifactId>

0 commit comments

Comments
 (0)