Automatic Release #19
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: Automatic Release | |
on: | |
schedule: | |
- cron: '0 0 * * 0' # Runs every Sunday at midnight UTC | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
update_version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
- name: Update version in libs.versions.toml | |
id: update_version | |
run: | | |
VERSION_FILE="gradle/libs.versions.toml" | |
CURRENT_DATE=$(date +'%Y.%m.%d') | |
VERSION_CODE=$(grep 'version-code =' $VERSION_FILE | awk -F'=' '{print $2}' | tr -d ' "') | |
NEW_VERSION_CODE=$((VERSION_CODE + 1)) | |
sed -i "s/version-name = \".*\"/version-name = \"$CURRENT_DATE\"/" $VERSION_FILE | |
sed -i "s/version-code = \".*\"/version-code = \"$NEW_VERSION_CODE\"/" $VERSION_FILE | |
echo "NEW_VERSION_NAME=$CURRENT_DATE" >> $GITHUB_ENV | |
echo "NEW_VERSION_CODE=$NEW_VERSION_CODE" >> $GITHUB_ENV | |
- name: Set branch name | |
id: set_branch_name | |
run: | | |
BRANCH_NAME="auto-update-$(date +'%Y%m%d%H%M%S')" | |
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV | |
- name: Create a Pull Request | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "Automatic release: v${{ env.NEW_VERSION_NAME }} (${{ env.NEW_VERSION_CODE }})" | |
base: "main" | |
branch: ${{ env.BRANCH_NAME }} | |
title: "Automatic release: v${{ env.NEW_VERSION_NAME }} (${{ env.NEW_VERSION_CODE }})" | |
body: "This PR updates the version-name to v${{ env.NEW_VERSION_NAME }} and increments the version-code to ${{ env.NEW_VERSION_CODE }}." | |
labels: auto-update | |
author: "GitHub Actions <[email protected]>" | |
committer: "GitHub Actions <[email protected]>" | |
delete-branch: true |