-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (149 loc) · 5.53 KB
/
release.yml
File metadata and controls
178 lines (149 loc) · 5.53 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Release
on:
push:
branches: [ main ]
workflow_dispatch:
inputs:
version_bump:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
env:
CARGO_TERM_COLOR: always
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android
- name: Install cargo-ndk
run: cargo install cargo-ndk
- name: Install Android NDK
run: |
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "ndk;26.1.10909125"
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/26.1.10909125" >> $GITHUB_ENV
echo "ANDROID_NDK_ROOT=$ANDROID_HOME/ndk/26.1.10909125" >> $GITHUB_ENV
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-deps-${{ hashFiles('**/Cargo.lock', '**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-deps-
# PROPER VERSION MANAGEMENT
- name: Calculate next version
id: version
run: |
# Debug: Show all current tags
echo "All tags:"
git tag -l | sort -V | tail -5 || echo "No tags found"
# Get current version from git tags, not build files
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0-alpha")
echo "Latest tag: $LATEST_TAG"
# Debug: Show current build.gradle version
echo "Current build.gradle version:"
grep "version = '" build.gradle || echo "No version found in build.gradle"
# Parse version (remove 'v' prefix and '-alpha' suffix)
VERSION_NUM=$(echo $LATEST_TAG | sed 's/^v//' | sed 's/-alpha$//')
IFS='.' read -ra PARTS <<< "$VERSION_NUM"
MAJOR=${PARTS[0]:-0}
MINOR=${PARTS[1]:-1}
PATCH=${PARTS[2]:-0}
# Increment based on trigger
BUMP_TYPE="${{ github.event.inputs.version_bump || 'patch' }}"
case $BUMP_TYPE in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
patch) PATCH=$((PATCH + 1)) ;;
esac
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}-alpha"
NEW_TAG="v${NEW_VERSION}"
echo "New version: $NEW_VERSION"
echo "New tag: $NEW_TAG"
# Update build.gradle using sed (more reliable in CI)
sed -i "s/version = '[^']*'/version = '$NEW_VERSION'/g" build.gradle
# Verify update
UPDATED_VERSION=$(grep "version = '" build.gradle | head -1 | sed "s/.*version = '\([^']*\)'.*/\1/")
echo "Updated version in build.gradle: $UPDATED_VERSION"
if [ "$UPDATED_VERSION" != "$NEW_VERSION" ]; then
echo "ERROR: Failed to update build.gradle. Expected: $NEW_VERSION, Got: $UPDATED_VERSION"
cat build.gradle | grep -A2 -B2 "version ="
exit 1
fi
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT
# BUILD AND TEST FIRST
- name: Run tests
run: cargo test --verbose
- name: Build Rust JNI library
run: ./gradlew buildRustJNI
env:
AWS_LC_SYS_NO_ASM_aarch64_linux_android: 1
AWS_LC_SYS_NO_ASM: 1
- name: Build Android AAR
run: ./gradlew assembleRelease
# ONLY PUBLISH AFTER SUCCESSFUL BUILD
- name: Publish to GitHub Packages
run: ./gradlew publishReleasePublicationToGitHubPackagesRepository
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
# CREATE RELEASE ATOMICALLY
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.tag }}
name: Release ${{ steps.version.outputs.tag }}
body: |
## Thread Safety Release ${{ steps.version.outputs.version }}
### Changes
- Per-replica thread safety for JNI operations
- Graceful mutex poisoning recovery
- Comprehensive concurrent operation tests
### Usage
```gradle
implementation 'com.github.craigdallimore:taskchampion-jni:${{ steps.version.outputs.tag }}'
```
files: |
build/outputs/aar/*.aar
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# COMMIT VERSION BUMP AFTER RELEASE
- name: Commit version bump
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add build.gradle
git commit -m "chore: bump version to ${{ steps.version.outputs.version }}"
git push