diff --git a/.mokogitea/workflows/pre-release.yml b/.mokogitea/workflows/pre-release.yml index 162b08f..a85031a 100644 --- a/.mokogitea/workflows/pre-release.yml +++ b/.mokogitea/workflows/pre-release.yml @@ -14,9 +14,10 @@ name: "Universal: Pre-Release" on: pull_request: - types: [closed] + types: [opened, ready_for_review, closed] branches: - dev + - main workflow_dispatch: inputs: stability: @@ -39,11 +40,12 @@ env: jobs: build: - name: "Build Pre-Release (${{ inputs.stability || 'development' }})" + name: "Build Pre-Release (${{ inputs.stability || (github.event.pull_request.base.ref == 'main' && 'release-candidate') || 'development' }})" runs-on: release if: >- github.event_name == 'workflow_dispatch' || - (github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev') + (github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev') || + (github.event.action != 'closed' && github.event.pull_request.base.ref == 'main') steps: - name: Checkout @@ -73,10 +75,35 @@ jobs: run: | php ${MOKO_CLI}/manifest_read.php --path . --github-output + - name: Rename branch to rc on PR draft to main + if: >- + github.event.action != 'closed' && + github.event.pull_request.base.ref == 'main' + run: | + HEAD_BRANCH="${{ github.event.pull_request.head.ref }}" + if [ "$HEAD_BRANCH" != "rc" ]; then + git config --local user.email "gitea-actions[bot]@mokoconsulting.tech" + git config --local user.name "gitea-actions[bot]" + git remote set-url origin "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git" + git checkout -b rc + git push origin rc 2>&1 || true + # Update PR head branch via API + curl -s -X PATCH \ + -H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "{\"head\": \"rc\"}" \ + "${GITEA_URL}/api/v1/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" || true + fi + - name: Resolve metadata and bump version id: meta run: | - STABILITY="${{ inputs.stability || 'development' }}" + # Auto-detect RC when PR targets main + if [ "${{ github.event.pull_request.base.ref }}" = "main" ] && [ "${{ github.event.action }}" != "closed" ]; then + STABILITY="release-candidate" + else + STABILITY="${{ inputs.stability || 'development' }}" + fi case "$STABILITY" in development) SUFFIX="-dev"; TAG="development" ;; @@ -142,7 +169,7 @@ jobs: php ${MOKO_CLI}/release_create.php \ --path . --version "$VERSION" --tag "$TAG" \ --token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \ - --repo "${GITEA_REPO}" --branch dev --prerelease + --repo "${GITEA_REPO}" --branch "${{ github.ref_name }}" --prerelease - name: Build package and upload id: package