From 3cb687fc757435015731a0c5b7ecdc00771644e1 Mon Sep 17 00:00:00 2001 From: Miku <26039249+xMikux@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:57:08 +0800 Subject: [PATCH] ci: better version output (#46) --- .github/workflows/release_beta.yml | 2 +- .github/workflows/release_versionts.yml | 34 ++++++++++++++++++++++++ .github/workflows/resuable_version.yml | 35 ++++++++++++++++++------- 3 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/release_versionts.yml diff --git a/.github/workflows/release_beta.yml b/.github/workflows/release_beta.yml index 2c59db5c..a99c26a5 100644 --- a/.github/workflows/release_beta.yml +++ b/.github/workflows/release_beta.yml @@ -52,6 +52,6 @@ jobs: needs: [ version-gen, config-upload, res-packer ] uses: ./.github/workflows/resuable_release_modrinth.yml with: - version: ${{ needs.version-gen.outputs.version_name }} + version: ${{ needs.version-gen.outputs.version_sha_name }} secrets: MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release_versionts.yml b/.github/workflows/release_versionts.yml new file mode 100644 index 00000000..0e26d78d --- /dev/null +++ b/.github/workflows/release_versionts.yml @@ -0,0 +1,34 @@ +name: Release | Version Test + +on: + workflow_dispatch: {} + push: + +jobs: + version-gen-beta: + name: Version Generator + uses: ./.github/workflows/resuable_version.yml + if: | + github.repository == 'xMikux/Slimefun-Resourcepack' + with: + release_type: "beta" + version-gen-release: + name: Version Generator + uses: ./.github/workflows/resuable_version.yml + if: | + github.repository == 'xMikux/Slimefun-Resourcepack' + with: + release_type: "release" + generate-version-summary: + name: Generate Version Summary + runs-on: ubuntu-latest + needs: [ version-gen-beta, version-gen-release ] + steps: + - name: Act - Summary + run: | + echo "# Version Summary" >> $GITHUB_STEP_SUMMARY + echo "- Current Version: ${{ needs.version-gen-release.outputs.version_semver_current_name }}" >> $GITHUB_STEP_SUMMARY + echo "- Next Version: ${{ needs.version-gen-release.outputs.version_semver_next_name }}" >> $GITHUB_STEP_SUMMARY + echo "- SHA Version: ${{ needs.version-gen-release.outputs.version_sha_name }}" >> $GITHUB_STEP_SUMMARY + echo "- PackFormat - Beta: ${{ needs.version-gen-beta.outputs.pack_version_name }}" >> $GITHUB_STEP_SUMMARY + echo "- PackFormat - Release: ${{ needs.version-gen-release.outputs.pack_version_name }}" >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/.github/workflows/resuable_version.yml b/.github/workflows/resuable_version.yml index f8d60d1f..ed7b0e15 100644 --- a/.github/workflows/resuable_version.yml +++ b/.github/workflows/resuable_version.yml @@ -8,9 +8,15 @@ on: required: false default: "beta" outputs: - version_name: - description: "The version name (ex: git-abcdef or v1.0.0 )" - value: ${{ jobs.version_maker.outputs.version_name }} + version_sha_name: + description: "The sha version name (ex: git-abcdef or v1.0.0 )" + value: ${{ jobs.version_maker.outputs.version_sha_name }} + version_semver_current_name: + description: "The semver current version name" + value: ${{ jobs.version_maker.outputs.version_semver_current_name }} + version_semver_next_name: + description: "The semver next version name" + value: ${{ jobs.version_maker.outputs.version_semver_next_name }} pack_version_name: description: "The pack format will use name (ex: Beta git-abcdef or Release v1.0.0)" value: ${{ jobs.version_maker.outputs.pack_version_name }} @@ -20,23 +26,34 @@ jobs: name: Make Version runs-on: ubuntu-latest outputs: - version_name: ${{ steps.git_version.outputs.short_sha }} + version_sha_name: ${{ steps.version_list.outputs.sha_name }} + version_semver_current_name: ${{ steps.version_list.outputs.semver_current_name }} + version_semver_next_name: ${{ steps.version_list.outputs.semver_next_name }} pack_version_name: ${{ steps.pack_version_name.outputs.version_name }} steps: - name: Setup - Checkout Repository uses: actions/checkout@v4 - - name: Version - Get Current Version - id: git_version + name: Get Next Version + id: semver + uses: ietf-tools/semver-action@v1 + with: + token: ${{ github.token }} + branch: main + - + name: Version - Get Versions + id: version_list run: | - echo "short_sha=git-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" + echo "sha_name=git-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" + echo "semver_current_name=${{ steps.semver.outputs.current }}" >> "$GITHUB_OUTPUT" + echo "semver_next_name=${{ steps.semver.outputs.next }}" >> "$GITHUB_OUTPUT" - name: Pack Format - Version Name id: pack_version_name run: | if [ "${{ inputs.release_type }}" == "beta" ]; then - echo "version_name=§dBeta §f${{ steps.git_version.outputs.short_sha }}" >> "$GITHUB_OUTPUT" + echo "version_name=§dBeta §f${{ steps.version_list.outputs.sha_name }}" >> "$GITHUB_OUTPUT" elif [ "${{ inputs.release_type }}" == "release" ]; then - echo "version_name=§bRelease §fvABC?" >> "$GITHUB_OUTPUT" + echo "version_name=§bRelease §f${{ steps.version_list.outputs.semver_next_name }}" >> "$GITHUB_OUTPUT" fi