Skip to content

Commit

Permalink
chore: update workflow release and version updater
Browse files Browse the repository at this point in the history
  • Loading branch information
wax911 committed Feb 25, 2024
1 parent 4b06463 commit 2fa3df5
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 34 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,41 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v6
id: release_drafter
with:
config-name: release-drafter-config.yml
disable-autolabeler: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version
id: version
run: echo "${{ steps.release_drafter.outputs.resolved_version }}" > VERSION
- name: Calculate code
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
id: code
run: |
IFS='.' read -ra VER <<< "$(cat VERSION)"
MAJOR=$((VER[0] * 1000000000))
MINOR=$((VER[1] * 1000000))
PATCH=$((VER[2] * 1000))
CODE=$((MAJOR + MINOR + PATCH))
echo "version=$(cat VERSION)" > gradle/version.properties
echo "code=$CODE" >> gradle/version.properties
echo "name=v$(cat VERSION)" >> gradle/version.properties
- name: Show version
run: cat gradle/version.properties

- name: Push auto generated version file
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "automation: update version.properties"
branch: platform/update-version-meta-data
commit_options: '--no-verify --signoff'
file_pattern: 'gradle/version.properties'
repository: .
commit_author: Author <actions@github.com>
create_branch: true
push_options: '--force'
skip_fetch: true
56 changes: 22 additions & 34 deletions .github/workflows/version-updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,33 @@ name: version-update

on:
push:
tags:
- '*'
branches:
- platform/update-version-meta-data


permissions:
pull-requests: write

jobs:
generate-release-file:
version-update:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: platform/update-version-meta-data

- name: Extract version
id: version
run: echo "${GITHUB_REF#refs/tags/}" > VERSION

- name: Calculate version code
id: code
run: |
IFS='.' read -ra VER <<< "$(cat VERSION)"
MAJOR=$((VER[0] * 1000000000))
MINOR=$((VER[1] * 1000000))
PATCH=$((VER[2] * 1000))
CODE=$((MAJOR + MINOR + PATCH))
echo "version=$(cat VERSION)" > gradle/version.properties
echo "code=$CODE" >> gradle/version.properties
echo "name=v$(cat VERSION)" >> gradle/version.properties
- name: Show version
run: cat gradle/version.properties

- name: Commit version.properties
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add gradle/version.properties
git commit -m "Bump version to $(cat VERSION)"
- name: Push changes
uses: ad-m/github-push-action@master
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: develop
directory: .
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "automation: update version.properties"
author: "Author <actions@github.com>"
title: "platform: automated version update"
body: |
This PR was automatically generated to update version.properties.
branch: platform/update-version-meta-data
base: develop
labels: "skip-changelog"
assignees: "wax911"
reviewers: "wax911"

0 comments on commit 2fa3df5

Please sign in to comment.