Manual bump to v0.1.5-alpha to avoid GitHub Packages conflicts #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |