Skip to content

ci: Updated version

ci: Updated version #8

Workflow file for this run

name: Release
on:
push:
branches:
- main
env:
VERSION_NAME: 0.0.1+2 # Update this value for each release
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
token: ${{ secrets.TOKEN }}
persist-credentials: true
- name: Setup gradle.properties
run: |
# Create a minimal gradle.properties with only necessary properties for CI
echo "android.useAndroidX=true" > gradle.properties
echo "VERSION_NAME=${{ env.VERSION_NAME }}" >> gradle.properties
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Build Compose Permissions Library
run: ./gradlew :permissions-compose:assembleRelease -Dandroid.useAndroidX=true
- name: Extract Version
id: get_version
run: |
VERSION=$(grep "^VERSION_NAME=" gradle.properties | cut -d '=' -f2)
echo "Version found: $VERSION"
echo "version=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Generate Changelog
id: generate_changelog
run: |
# Get the previous tag; if none exists, use the initial commit.
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
echo "No previous tag found, using initial commit."
PREV_TAG=$(git rev-list --max-parents=0 HEAD)
fi
echo "Previous tag: $PREV_TAG"
CHANGELOG=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s")
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Git Tag
run: |
git config --global user.email "[email protected]"
git config --global user.name "Cavin"
git tag -a v${{ env.version }} -m "Release v${{ env.version }}"
git push origin v${{ env.version }}
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: v${{ env.version }}
release_name: "Release v${{ env.version }}"
body: |
## Changelog
${{ steps.generate_changelog.outputs.changelog }}
draft: false
prerelease: false
- name: Upload Release Artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: permissions-compose/build/outputs/aar/permissions-compose-release.aar
asset_name: permissions-compose-${{ env.version }}.aar
asset_content_type: application/octet-stream