-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (87 loc) · 3.24 KB
/
version-bump-dev.yml
File metadata and controls
99 lines (87 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Version Bump
on:
push:
branches:
- "dev"
- "release"
- "release/**"
paths-ignore:
- "version.properties"
permissions:
contents: read
concurrency:
group: version-bump-${{ github.ref }}
cancel-in-progress: true
jobs:
bump-build:
if: ${{ !endsWith(github.actor, '[bot]') }}
runs-on: ubuntu-latest
steps:
- name: Generate app token
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.VERSION_BUMP_APP_ID }}
private-key: ${{ secrets.VERSION_BUMP_APP_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Setup Java 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- name: Setup Kotlin CLI
shell: bash
run: |
set -euo pipefail
KOTLIN_VERSION="$(grep '^kotlin = "' gradle/libs.versions.toml | sed -E 's/^kotlin = "([^"]+)"/\1/')"
ZIP_PATH="$RUNNER_TEMP/kotlin-compiler.zip"
DEST_DIR="$RUNNER_TEMP/kotlin-cli"
curl -fsSL "https://github.com/JetBrains/kotlin/releases/download/v${KOTLIN_VERSION}/kotlin-compiler-${KOTLIN_VERSION}.zip" -o "$ZIP_PATH"
unzip -q "$ZIP_PATH" -d "$DEST_DIR"
echo "$DEST_DIR/kotlinc/bin" >> "$GITHUB_PATH"
"$DEST_DIR/kotlinc/bin/kotlinc" -version
- name: Bump build number
id: bump
shell: bash
run: |
set -euo pipefail
kotlinc -script .github/scripts/version.main.kts bump build version.properties
- name: Detect version bump changes
id: diff
shell: bash
run: |
set -euo pipefail
if git diff --quiet -- version.properties; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No version change detected"
exit 0
fi
echo "changed=true" >> "$GITHUB_OUTPUT"
- name: Resolve app bot identity
if: steps.diff.outputs.changed == 'true'
id: app-bot
shell: bash
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
set -euo pipefail
echo "user_id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
- name: Commit version bump
if: steps.diff.outputs.changed == 'true'
shell: bash
env:
GIT_AUTH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
set -euo pipefail
git remote set-url origin "https://x-access-token:${GIT_AUTH_TOKEN}@github.com/${{ github.repository }}.git"
git config user.name "${{ steps.app-token.outputs.app-slug }}[bot]"
git config user.email "${{ steps.app-bot.outputs.user_id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com"
git add version.properties
git commit -m "[skip CI] chore: bump build to ${{ steps.bump.outputs.current_build }} for ${{ steps.bump.outputs.current_dev }} on ${{ github.ref_name }}"
git push origin HEAD:${{ github.ref_name }}