Skip to content

Commit 6da2865

Browse files
committed
ci: add workflow to build and release artifacts
Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
1 parent aa977f9 commit 6da2865

1 file changed

Lines changed: 105 additions & 0 deletions

File tree

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Build Kotlin Patched Artifact
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
tags:
8+
- '*'
9+
workflow_dispatch: {}
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up JDK
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: temurin
23+
java-version: 17
24+
25+
- name: Install dependencies
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y git curl unzip
29+
30+
- name: Get Kotlin source
31+
run: |
32+
./get_source.sh
33+
34+
- name: Apply patches
35+
run: |
36+
./patch.sh
37+
38+
- name: Build JAR
39+
run: |
40+
./build.sh
41+
42+
- name: Compute metadata
43+
id: meta
44+
run: |
45+
JAR=$(ls outputs/*.jar | head -n1)
46+
echo "jar=$JAR" >> $GITHUB_OUTPUT
47+
48+
NAME=$(basename "$JAR")
49+
echo "name=$NAME" >> $GITHUB_OUTPUT
50+
51+
SHA256=$(sha256sum "$JAR" | awk '{print $1}')
52+
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
53+
54+
VERSION=$(echo "$NAME" | sed -E 's/.*-([0-9]+\.[0-9]+\.[0-9]+)-SNAPSHOT.*/\1/')
55+
echo "version=$VERSION" >> $GITHUB_OUTPUT
56+
57+
- name: Upload artifact
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: kotlin-jar
61+
path: ${{ steps.meta.outputs.jar }}
62+
63+
release:
64+
needs: build
65+
runs-on: ubuntu-latest
66+
if: github.ref == 'refs/heads/main'
67+
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@v4
71+
72+
- name: Download artifact
73+
uses: actions/download-artifact@v4
74+
with:
75+
name: kotlin-jar
76+
path: outputs
77+
78+
- name: Extract metadata
79+
id: meta
80+
run: |
81+
JAR=$(ls outputs/*.jar | head -n1)
82+
NAME=$(basename "$JAR")
83+
84+
SHA256=$(sha256sum "$JAR" | awk '{print $1}')
85+
VERSION=$(echo "$NAME" | sed -E 's/.*-([0-9]+\.[0-9]+\.[0-9]+)-SNAPSHOT.*/\1/')
86+
87+
echo "jar=$JAR" >> $GITHUB_OUTPUT
88+
echo "name=$NAME" >> $GITHUB_OUTPUT
89+
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
90+
echo "version=$VERSION" >> $GITHUB_OUTPUT
91+
92+
- name: Create GitHub Release
93+
uses: softprops/action-gh-release@v2
94+
with:
95+
tag_name: ${{ steps.meta.outputs.version }}
96+
name: Kotlin ${{ steps.meta.outputs.version }} (patched)
97+
body: |
98+
Kotlin Version: ${{ steps.meta.outputs.version }}
99+
100+
Artifact: ${{ steps.meta.outputs.name }}
101+
102+
SHA256: ${{ steps.meta.outputs.sha256 }}
103+
files: ${{ steps.meta.outputs.jar }}
104+
env:
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)