diff --git a/.github/workflows/release-beta_publish.yml b/.github/workflows/release-publish.yml similarity index 58% rename from .github/workflows/release-beta_publish.yml rename to .github/workflows/release-publish.yml index 3537e35fd..8efdbbabe 100644 --- a/.github/workflows/release-beta_publish.yml +++ b/.github/workflows/release-publish.yml @@ -1,21 +1,34 @@ -name: Publish (Beta) +name: Release Beta (Actual) permissions: - contents: read + contents: write + actions: write on: - release: - types: [published] + workflow_dispatch: + inputs: + configuration: + description: 'Configuration to build (e.g., Release)' + required: true + type: string + version: + description: 'Version to release (e.g., 2.14.2)' + required: true + type: string + prerelease: + description: 'Is this a prerelease?' + required: false + type: boolean + default: true jobs: build: - if: ${{ github.event.release.prerelease }} strategy: matrix: include: - - configuration: Beta + - configuration: ${{ inputs.configuration }} architecture: x64 - - configuration: Beta + - configuration: ${{ inputs.configuration }} architecture: ARM64 fail-fast: false @@ -26,11 +39,8 @@ jobs: secrets: inherit changelog: - permissions: - contents: write runs-on: ubuntu-latest continue-on-error: true - if: ${{ github.event.release.prerelease }} steps: - name: Checkout all uses: actions/checkout@v4 @@ -43,26 +53,26 @@ jobs: - name: Generate changelog run: git-cliff --latest -o CHANGELOG.md - - name: Add changelog to release - uses: softprops/action-gh-release@v2.5.0 + - name: Create or update release + uses: softprops/action-gh-release@v3.0.0 with: - tag_name: ${{ github.event.release.tag_name }} + draft: true + tag_name: v${{ inputs.version }} + name: Release ${{ inputs.version }} body_path: CHANGELOG.md + prerelease: ${{ inputs.prerelease }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} rename_and_release: - permissions: - contents: write - actions: write needs: [build, changelog] runs-on: ubuntu-latest strategy: matrix: include: - - configuration: Beta + - configuration: ${{ inputs.configuration }} architecture: x64 - - configuration: Beta + - configuration: ${{ inputs.configuration }} architecture: ARM64 steps: - name: Download Build Artifact @@ -86,8 +96,10 @@ jobs: gpg --detach-sign --armor "PCL2_CE_${{ matrix.configuration }}_${{ matrix.architecture }}.exe" - name: Upload binary and signature to Release - uses: softprops/action-gh-release@v2.2.2 + uses: softprops/action-gh-release@v3.0.0 with: + draft: true + tag_name: v${{ inputs.version }} files: | PCL2_CE_${{ matrix.configuration }}_${{ matrix.architecture }}.exe PCL2_CE_${{ matrix.configuration }}_${{ matrix.architecture }}.exe.asc @@ -96,7 +108,26 @@ jobs: - name: Trigger MirrorChyanUploading run: | - gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_uploading.yml -f channel=beta -f arch=${{ matrix.architecture == 'x64' && 'x64' || 'arm64' }} + MRC_CHANNEL="stable" + if [ "${{ inputs.configuration }}" = "Beta" ]; then + MRC_CHANNEL="beta" + fi + + gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_uploading.yml -f channel=$MRC_CHANNEL -f arch=${{ matrix.architecture == 'x64' && 'x64' || 'arm64' }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish_draft: + needs: [rename_and_release] + runs-on: ubuntu-latest + steps: + - name: Publish Draft + uses: softprops/action-gh-release@v3.0.0 + with: + tag_name: v${{ inputs.version }} + + - name: Trigger MirrorChyanUploading + run: | gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release_note.yml env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-stable_publish.yml b/.github/workflows/release-stable_publish.yml deleted file mode 100644 index 80ccb2df7..000000000 --- a/.github/workflows/release-stable_publish.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: Publish (Release) - -permissions: - contents: read - -on: - release: - types: [published] - -jobs: - build: - if: ${{ !github.event.release.prerelease }} - strategy: - matrix: - include: - - configuration: Release - architecture: x64 - - configuration: Release - architecture: ARM64 - fail-fast: false - - uses: ./.github/workflows/reusable-build.yml - with: - configuration: ${{ matrix.configuration }} - architecture: ${{ matrix.architecture }} - secrets: inherit - - changelog: - permissions: - contents: write - runs-on: ubuntu-latest - continue-on-error: true - if: ${{ !github.event.release.prerelease }} - steps: - - name: Checkout all - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install git-cliff - uses: taiki-e/install-action@git-cliff - - - name: Generate changelog - run: git-cliff --latest -o CHANGELOG.md - - - name: Add changelog to release - uses: softprops/action-gh-release@v2.2.2 - with: - tag_name: ${{ github.event.release.tag_name }} - body_path: CHANGELOG.md - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - rename_and_release: - permissions: - contents: write - actions: write - needs: [build, changelog] - runs-on: ubuntu-latest - strategy: - matrix: - include: - - configuration: Release - architecture: x64 - - configuration: Release - architecture: ARM64 - steps: - - name: Download Build Artifact - uses: actions/download-artifact@v4 - with: - name: PCL2_CE_${{ matrix.configuration }}_${{ matrix.architecture }} - path: ./artifact - - - name: Rename binaries - run: | - mv "./artifact/Plain Craft Launcher 2.exe" "PCL2_CE_${{ matrix.configuration }}_${{ matrix.architecture }}.exe" - - - name: Import GPG key - uses: crazy-max/ghaction-import-gpg@v6 - with: - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.GPG_PASSPHRASE }} - - - name: Sign the binary - run: | - gpg --detach-sign --armor "PCL2_CE_${{ matrix.configuration }}_${{ matrix.architecture }}.exe" - - - name: Upload binary and signature to Release - uses: softprops/action-gh-release@v2.5.0 - with: - files: | - PCL2_CE_${{ matrix.configuration }}_${{ matrix.architecture }}.exe - PCL2_CE_${{ matrix.configuration }}_${{ matrix.architecture }}.exe.asc - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Trigger MirrorChyanUploading - run: | - gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_uploading.yml -f channel=stable -f arch=${{ matrix.architecture == 'x64' && 'x64' || 'arm64' }} - gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release_note.yml - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-trigger.yml b/.github/workflows/release-trigger.yml new file mode 100644 index 000000000..0439bc384 --- /dev/null +++ b/.github/workflows/release-trigger.yml @@ -0,0 +1,55 @@ +name: Release Trigger + +permissions: + contents: read + +on: + pull_request: + types: [closed] + +jobs: + trigger_release: + if: ${{ github.event.pull_request.merged == true }} + permissions: + actions: write + contents: write + runs-on: ubuntu-latest + steps: + - name: Extract version from PR title + id: extract + run: | + PR_TITLE="${{ github.event.pull_request.title }}" + echo "PR Title: $PR_TITLE" + + # 尝试匹配 "release-stable: VERSION" 或 "release-beta: VERSION" 格式,支持 SemVer(可选 v 前缀) + if [[ "$PR_TITLE" =~ (release-stable|release-beta):\ ?[vV]?([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?) ]]; then + VERSION="${BASH_REMATCH[2]}" + RELEASE_TYPE="${BASH_REMATCH[1]}" + + if [[ "$RELEASE_TYPE" == "release-beta" ]]; then + IS_BETA="true" + else + IS_BETA="false" + fi + + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "is_beta=$IS_BETA" >> $GITHUB_OUTPUT + echo "Extracted version: $VERSION, is_beta: $IS_BETA" + else + echo "Error: PR title does not match expected format 'release-stable: VERSION' or 'release-beta: VERSION' (SemVer)" + exit 1 + fi + + - name: Trigger Release Workflow + run: | + CONFIGURATION="Release" + if [[ "${{ steps.extract.outputs.is_beta }}" == "true" ]]; then + CONFIGURATION="Beta" + fi + + gh workflow run release-publish.yml \ + -f version=${{ steps.extract.outputs.version }} \ + -f configuration="${CONFIGURATION}" \ + -f prerelease=${{ steps.extract.outputs.is_beta }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}