From a01f46cfa1d81fd5f230b4f9e5d452d9ab824801 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 28 Mar 2024 21:54:05 +0200 Subject: [PATCH] chore: update workflows --- .github/workflows/release-drafter.yml | 38 ++++--------------------- .github/workflows/version-updater.yml | 40 +++++++++++++++++++++------ 2 files changed, 37 insertions(+), 41 deletions(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index abb12e3..2bd1e18 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -4,7 +4,7 @@ on: push: branches: - 'develop' - pull_request: + pull_request_target: # Only following types are handled by the action, but one can default to all as well types: [ opened, reopened, synchronize ] @@ -26,35 +26,9 @@ jobs: commitish: develop env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout repository - uses: actions/checkout@v4 - - name: Extract version - id: version - run: echo "${{ steps.release_drafter.outputs.resolved_version }}" > VERSION - - name: Calculate 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: Push auto generated version file - uses: stefanzweifel/git-auto-commit-action@v5 + - name: Repository Dispatch + uses: peter-evans/repository-dispatch@v3 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 - create_branch: true - push_options: '--force' - skip_fetch: true \ No newline at end of file + token: ${{ secrets.GITHUB_TOKEN }} + event-type: version-update-and-push + client-payload: '{"version": "${{ steps.release_drafter.outputs.resolved_version }}"}' diff --git a/.github/workflows/version-updater.yml b/.github/workflows/version-updater.yml index 1b62b29..f0baafb 100644 --- a/.github/workflows/version-updater.yml +++ b/.github/workflows/version-updater.yml @@ -1,34 +1,56 @@ name: version-update on: - push: - branches: - - platform/update-version-meta-data - + repository_dispatch: + types: [version-update-and-push] permissions: - pull-requests: write + contents: read jobs: version-update: + permissions: + contents: write + pull-requests: write runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Checkout repository uses: actions/checkout@v4 with: - ref: platform/update-version-meta-data + ref: develop + + - name: Extract version information to file + run: echo "${{ github.event.client_payload.version }}" > VERSION + + - name: Create version.properties using extracted version + 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: Clean up version information file + run: rm VERSION + + - name: Preview created version.properties + run: cat gradle/version.properties - name: Create Pull Request uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.GITHUB_TOKEN }} + signoff: true + delete-branch: true commit-message: "automation: update version.properties" author: "Author " title: "platform: automated version update" body: | - This PR was automatically generated to update version.properties. + This PR was automatically generated to update `version.properties` branch: platform/update-version-meta-data - base: develop labels: "skip-changelog" assignees: "wax911" reviewers: "wax911"