Skip to content

Commit 145fb97

Browse files
committed
Create publish.yml
1 parent 4d0a317 commit 145fb97

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/publish.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Publish Kobweb CLI to package managers
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
dryRun:
7+
description: 'Dry run'
8+
type: boolean
9+
required: true
10+
default: true
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: actions/setup-java@v4
19+
with:
20+
distribution: temurin
21+
java-version: 11
22+
23+
- name: Setup Gradle
24+
uses: gradle/gradle-build-action@v3
25+
26+
- name: Add secret Gradle properties
27+
env:
28+
GRADLE_PROPERTIES: ${{ secrets.VARABYTE_GRADLE_PROPERTIES }}
29+
run: |
30+
mkdir -p ~/.gradle/
31+
echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV
32+
echo "${GRADLE_PROPERTIES}" > ~/.gradle/gradle.properties
33+
34+
- name: Set dry run option
35+
run: |
36+
echo "kobweb.cli.jreleaser.dryrun=${{ github.event.inputs.dryRun }}" >> ~/.gradle/gradle.properties
37+
38+
# Force Gradle to run early so we don't capture the "Downloading Gradle" message in
39+
# the output of our following steps
40+
- name: Force Gradle download
41+
run: ./gradlew --version
42+
43+
- name: Get Kobweb CLI Version
44+
id: cli_version
45+
run: |
46+
echo "VERSION=$(./gradlew -q :kobweb:printVersion)" >> "$GITHUB_OUTPUT"
47+
48+
- name: Download Release Assets
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
CLI_VERSION: ${{ steps.cli_version.outputs.VERSION }}
52+
run: |
53+
ASSET_ZIP="kobweb-$CLI_VERSION.zip"
54+
ASSET_TAR="kobweb-$CLI_VERSION.tar"
55+
# Need to put files here so jreleaser can find them
56+
ASSET_PATH="kobweb/build/distributions"
57+
mkdir -p $ASSET_PATH
58+
# Download assets using GitHub API
59+
curl -sL -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/octet-stream" \
60+
"$(curl -sL -H "Authorization: token $GITHUB_TOKEN" \
61+
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/v$CLI_VERSION" | jq -r ".assets[] | select(.name==\"$ASSET_ZIP\").url")" \
62+
-o "$ASSET_PATH/$ASSET_ZIP"
63+
curl -sL -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/octet-stream" \
64+
"$(curl -sL -H "Authorization: token $GITHUB_TOKEN" \
65+
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/v$CLI_VERSION" | jq -r ".assets[] | select(.name==\"$ASSET_TAR\").url")" \
66+
-o "$ASSET_PATH/$ASSET_TAR"
67+
68+
echo "Zip checksum $(sha256sum $ASSET_PATH/$ASSET_ZIP)"
69+
echo "Tar checksum $(sha256sum $ASSET_PATH/$ASSET_TAR)"
70+
71+
- name: Publish Kobweb CLI to package managers
72+
run: ./gradlew :kobweb:jreleaserPublish

0 commit comments

Comments
 (0)