Adds a link to the GitHub repository in the About screen. #1
This file contains 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: Version Bump | |
on: | |
push: | |
branches: | |
- dev | |
- stable | |
paths-ignore: | |
- '**.md' | |
- '.gitignore' | |
- '.github/**' | |
jobs: | |
version-bump: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Git | |
run: | | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email '[email protected]' | |
- name: Calculate Version | |
id: version | |
run: | | |
if [[ "${{ github.ref }}" == "refs/heads/stable" ]]; then | |
# Stable branch: major.minor.0 | |
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0") | |
MAJOR=$(echo $LAST_TAG | cut -d. -f1 | sed 's/v//') | |
MINOR=$(echo $LAST_TAG | cut -d. -f2) | |
NEW_VERSION="$MAJOR.$((MINOR + 1)).0" | |
else | |
# Dev branch: major.minor.patch | |
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0") | |
MAJOR=$(echo $LAST_TAG | cut -d. -f1 | sed 's/v//') | |
MINOR=$(echo $LAST_TAG | cut -d. -f2) | |
PATCH=$(echo $LAST_TAG | cut -d. -f3) | |
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" | |
fi | |
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
echo "::set-output name=version::$NEW_VERSION" | |
- name: Update Version in build.gradle | |
run: | | |
VERSION=${{ steps.version.outputs.version }} | |
MAJOR=$(echo $VERSION | cut -d. -f1) | |
MINOR=$(echo $VERSION | cut -d. -f2) | |
PATCH=$(echo $VERSION | cut -d. -f3) | |
sed -i "s/def versionMajor = .*/def versionMajor = $MAJOR/" app/build.gradle | |
sed -i "s/def versionMinor = .*/def versionMinor = $MINOR/" app/build.gradle | |
sed -i "s/def versionPatch = .*/def versionPatch = $PATCH/" app/build.gradle | |
- name: Commit Version Bump | |
run: | | |
git add app/build.gradle | |
git commit -m "chore: bump version to v${{ steps.version.outputs.version }}" | |
git tag "v${{ steps.version.outputs.version }}" | |
git push | |
git push --tags |