From da28e2cc37c1b2f18c4e49c4c63e9da8611c6dcc Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Wed, 10 Jan 2024 19:04:42 -0500 Subject: [PATCH] CI: fix flatpak cron and add a way to manually kick off a release (#10567) * CI: fix mistake stopping flatpak cron from running * CI: add a way to manually kick off releases with a custom tag * cmake: handle edge-case where a commit can have multiple tags * CI: set release channel appropriately when it's a stable release --- .github/workflows/cron_publish_flatpak.yml | 1 + .github/workflows/linux_build_flatpak.yml | 11 ++++++ .github/workflows/linux_build_qt.yml | 11 ++++++ .github/workflows/macos_build.yml | 11 ++++++ .github/workflows/release_cut_new.yml | 45 ++++++++++++++-------- .github/workflows/windows_build_qt.yml | 11 ++++++ cmake/Pcsx2Utils.cmake | 19 +++++++-- 7 files changed, 91 insertions(+), 18 deletions(-) diff --git a/.github/workflows/cron_publish_flatpak.yml b/.github/workflows/cron_publish_flatpak.yml index cdc62214d6..6d121ebe11 100644 --- a/.github/workflows/cron_publish_flatpak.yml +++ b/.github/workflows/cron_publish_flatpak.yml @@ -33,6 +33,7 @@ jobs: uses: ./.github/workflows/linux_build_flatpak.yml with: jobName: "Qt" + artifactPrefixName: "PCSX2-linux-Qt-x64-flatpak" compiler: clang cmakeflags: "" publish: true diff --git a/.github/workflows/linux_build_flatpak.yml b/.github/workflows/linux_build_flatpak.yml index 2f2aff9fdc..5a02be3115 100644 --- a/.github/workflows/linux_build_flatpak.yml +++ b/.github/workflows/linux_build_flatpak.yml @@ -39,6 +39,10 @@ on: required: false type: boolean default: false + stableBuild: + required: false + type: boolean + default: false jobs: build_linux: @@ -59,6 +63,13 @@ jobs: if: ${{ inputs.fetchTags }} run: git fetch --tags --no-recurse-submodules + - name: Add stable release identifier file + if: ${{ inputs.stableBuild == true || inputs.stableBuild == 'true' }} + shell: bash + run: | + echo "#define DEFAULT_UPDATER_CHANNEL \"stable\"" > ./pcsx2-qt/DefaultUpdaterChannel.h + cat ./pcsx2-qt/DefaultUpdaterChannel.h + - name: Prepare Artifact Metadata id: artifact-metadata shell: bash diff --git a/.github/workflows/linux_build_qt.yml b/.github/workflows/linux_build_qt.yml index 8dbb565cbe..2fec3ac5ac 100644 --- a/.github/workflows/linux_build_qt.yml +++ b/.github/workflows/linux_build_qt.yml @@ -39,6 +39,10 @@ on: required: false type: boolean default: false + stableBuild: + required: false + type: boolean + default: false jobs: build_linux: @@ -72,6 +76,13 @@ jobs: if: ${{ inputs.fetchTags }} run: git fetch --tags --no-recurse-submodules + - name: Add stable release identifier file + if: ${{ inputs.stableBuild == true || inputs.stableBuild == 'true' }} + shell: bash + run: | + echo "#define DEFAULT_UPDATER_CHANNEL \"stable\"" > ./pcsx2-qt/DefaultUpdaterChannel.h + cat ./pcsx2-qt/DefaultUpdaterChannel.h + - name: Prepare Artifact Metadata id: artifact-metadata shell: bash diff --git a/.github/workflows/macos_build.yml b/.github/workflows/macos_build.yml index 0a773987de..1f7bd19e09 100644 --- a/.github/workflows/macos_build.yml +++ b/.github/workflows/macos_build.yml @@ -21,6 +21,10 @@ on: required: false type: boolean default: false + stableBuild: + required: false + type: boolean + default: false jobs: build_macos: @@ -47,6 +51,13 @@ jobs: if: ${{ inputs.fetchTags }} run: git fetch --tags --no-recurse-submodules + - name: Add stable release identifier file + if: ${{ inputs.stableBuild == true || inputs.stableBuild == 'true' }} + shell: bash + run: | + echo "#define DEFAULT_UPDATER_CHANNEL \"stable\"" > ./pcsx2-qt/DefaultUpdaterChannel.h + cat ./pcsx2-qt/DefaultUpdaterChannel.h + - name: Use Xcode 14.3.1 run: sudo xcode-select -s /Applications/Xcode_14.3.1.app diff --git a/.github/workflows/release_cut_new.yml b/.github/workflows/release_cut_new.yml index d6803f2666..d0b6d89fbe 100644 --- a/.github/workflows/release_cut_new.yml +++ b/.github/workflows/release_cut_new.yml @@ -10,16 +10,19 @@ on: push: branches: - master - # TODO - future work - # workflow_dispatch: - # inputs: - # isStable: - # description: 'Should it be a stable release?' - # required: true - # default: 'false' - # versionTag: - # description: 'The version to tag with' - # required: true + workflow_dispatch: + inputs: + is_prelease: + description: 'Should be a pre-release?' + required: true + default: 'true' + type: choice + options: + - 'true' + - 'false' + tag_value: + description: 'Create a new release from latest master with the given tag, if this is left blank it will bump the patch version. You dont need to include the "v" prefix' + required: false permissions: contents: write @@ -42,6 +45,8 @@ jobs: github_token: ${{ github.token }} tag_prefix: v default_bump: patch + # if set, it will overwrite the bump settings + custom_tag: ${{ github.event.inputs.tag_value == '' && null || github.event.inputs.tag_value }} # TODO - we could do this and remove the node.js script, but auto-generated notes only work # with PRs -- not commits (determine how much we care). @@ -62,9 +67,18 @@ jobs: node index.js mv ./release-notes.md ${GITHUB_WORKSPACE}/release-notes.md - - name: Create a GitHub Release + - name: Create a GitHub Release (Manual) uses: softprops/action-gh-release@v1 - if: steps.tag_version.outputs.new_tag + if: steps.tag_version.outputs.new_tag && github.event_name == 'workflow_dispatch' + with: + body_path: ./release-notes.md + draft: true + prerelease: ${{ github.event_name != 'workflow_dispatch' || inputs.is_prelease == 'true' }} + tag_name: ${{ steps.tag_version.outputs.new_tag }} + + - name: Create a GitHub Release (Push) + uses: softprops/action-gh-release@v1 + if: steps.tag_version.outputs.new_tag && github.event_name != 'workflow_dispatch' with: body_path: ./release-notes.md draft: true @@ -86,6 +100,7 @@ jobs: cmakeflags: "" buildAppImage: true fetchTags: true + stableBuild: ${{ github.event_name == 'workflow_dispatch' && inputs.is_prelease == 'false' }} secrets: inherit build_linux_flatpak: @@ -102,6 +117,7 @@ jobs: branch: "stable" publish: false fetchTags: true + stableBuild: ${{ github.event_name == 'workflow_dispatch' && inputs.is_prelease == 'false' }} secrets: inherit # Windows @@ -118,6 +134,7 @@ jobs: buildSystem: cmake cmakeFlags: -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl fetchTags: true + stableBuild: ${{ github.event_name == 'workflow_dispatch' && inputs.is_prelease == 'false' }} secrets: inherit # MacOS @@ -131,6 +148,7 @@ jobs: jobName: "MacOS Build" artifactPrefixName: "PCSX2-macos-Qt" fetchTags: true + stableBuild: ${{ github.event_name == 'workflow_dispatch' && inputs.is_prelease == 'false' }} secrets: inherit # Upload the Artifacts @@ -163,9 +181,6 @@ jobs: working-directory: ./ci-artifacts/ run: for d in *windows*/; do 7z a "${d}asset.7z" ./$d/*; done - # Artifact Naming: - # MacOS: PCSX2--macOS-[additional hyphen seperated tags] - # Windows|Linux: PCSX2---<32bit|64bit>--[additional hyphen seperated tags] - name: Name and Upload the Release Assets env: GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/windows_build_qt.yml b/.github/workflows/windows_build_qt.yml index 3f16d49d1a..57e154ef0e 100644 --- a/.github/workflows/windows_build_qt.yml +++ b/.github/workflows/windows_build_qt.yml @@ -40,6 +40,10 @@ on: required: false type: boolean default: false + stableBuild: + required: false + type: boolean + default: false jobs: build_windows_qt: @@ -61,6 +65,13 @@ jobs: if: ${{ inputs.fetchTags }} run: git fetch --tags --no-recurse-submodules + - name: Add stable release identifier file + if: ${{ inputs.stableBuild == true || inputs.stableBuild == 'true' }} + shell: bash + run: | + echo "#define DEFAULT_UPDATER_CHANNEL \"stable\"" > ./pcsx2-qt/DefaultUpdaterChannel.h + cat ./pcsx2-qt/DefaultUpdaterChannel.h + - name: Prepare Artifact Metadata id: artifact-metadata shell: bash diff --git a/cmake/Pcsx2Utils.cmake b/cmake/Pcsx2Utils.cmake index 36ebd4dd44..03e2bc4c0e 100644 --- a/cmake/Pcsx2Utils.cmake +++ b/cmake/Pcsx2Utils.cmake @@ -56,11 +56,24 @@ function(get_git_version_info) OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) - EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} tag --points-at HEAD - OUTPUT_VARIABLE PCSX2_GIT_TAG + EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} tag --points-at HEAD --sort=version:refname + OUTPUT_VARIABLE PCSX2_GIT_TAG_LIST + RESULT_VARIABLE TAG_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) + # CAUTION: There is a race here, this solves the problem of a commit being tagged multiple times (take the last tag) + # however, if simultaneous builds are pushing tags to the same commit you might get inconsistent results (it's a race) + # + # The easy solution is, don't do that, but just something to be aware of. + if(PCSX2_GIT_TAG_LIST AND TAG_RESULT EQUAL 0) + string(REPLACE "\n" ";" PCSX2_GIT_TAG_LIST "${PCSX2_GIT_TAG_LIST}") + if (PCSX2_GIT_TAG_LIST) + list(GET PCSX2_GIT_TAG_LIST -1 PCSX2_GIT_TAG) + message("Using tag: ${PCSX2_GIT_TAG}") + endif() + endif() + EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD OUTPUT_VARIABLE PCSX2_GIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE @@ -111,7 +124,7 @@ function(write_svnrev_h) ) endif() else() - file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h + file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h "#define SVN_REV ${PCSX2_WC_TIME}ll\n" "#define GIT_TAG \"${PCSX2_GIT_TAG}\"\n" "#define GIT_TAGGED_COMMIT 0\n"