Skip to content

Commit

Permalink
Fix automatic_release.yml (Attempt 4)
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Jul 6, 2024
1 parent f8537a1 commit 550223c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/automatic_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,20 @@ jobs:
echo "NEW_VERSION_NAME=$CURRENT_DATE" >> $GITHUB_ENV
echo "NEW_VERSION_CODE=$NEW_VERSION_CODE" >> $GITHUB_ENV
- name: Commit and push changes
- name: Create a new branch, commit and push changes
run: |
NEW_BRANCH="auto-update-$(date +'%Y%m%d%H%M%S')"
git checkout -b $NEW_BRANCH
git add gradle/libs.versions.toml
git commit -m "Automatic release - v${{ env.NEW_VERSION_NAME }} (${{ env.NEW_VERSION_CODE }})"
git push
git push --set-upstream origin $NEW_BRANCH
- name: Create and push tag
run: |
git tag v${{ env.NEW_VERSION_NAME }}-${{ env.NEW_VERSION_CODE }}
git push origin v${{ env.NEW_VERSION_NAME }}-${{ env.NEW_VERSION_CODE }}
- name: Create a Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Automatic release - v${{ env.NEW_VERSION_NAME }} (${{ env.NEW_VERSION_CODE }})"
branch: $NEW_BRANCH
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
35 changes: 35 additions & 0 deletions .github/workflows/create_release_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create Tag for Release

on:
pull_request:
types: [closed]

jobs:
create_tag:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'auto-update')
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags

- name: Set up Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- name: Get version name and code from file
id: get_version
run: |
VERSION_NAME=$(grep 'version-name =' gradle/libs.versions.toml | awk -F'=' '{print $2}' | tr -d ' "')
VERSION_CODE=$(grep 'version-code =' gradle/libs.versions.toml | awk -F'=' '{print $2}' | tr -d ' "')
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
- name: Create and push tag
run: |
TAG_NAME="v${{ env.VERSION_NAME }}-${{ env.VERSION_CODE }}"
git tag $TAG_NAME
git push origin $TAG_NAME

0 comments on commit 550223c

Please sign in to comment.