WIP IsOnCloseButton
#512
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| paths-ignore: | |
| - ".clang-format" | |
| - ".gitignore" | |
| - "*.md" | |
| - "LICENSE" | |
| - "setdll/**" | |
| - "src/version.h" | |
| - ".github/ISSUE_TEMPLATE/**" | |
| - ".github/workflows/delete_old_workflow_runs.yml" | |
| - ".github/workflows/genReleaseNote.sh" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version (SemVer)' | |
| required: false | |
| build_mode: | |
| description: 'Build mode' | |
| required: false | |
| default: 'release' | |
| type: choice | |
| options: | |
| - release | |
| - debug | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| - name: build_x86 | |
| arch: x86 | |
| - name: build_x64 | |
| arch: x64 | |
| - name: build_arm64 | |
| arch: arm64 | |
| name: ${{ matrix.name }} | |
| runs-on: windows-2025 | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: 'true' | |
| - name: Update version.h | |
| shell: bash | |
| run: | | |
| if [ "${{ github.event_name }}" == "push" ]; then | |
| COMMIT_HASH=$(git rev-parse --short HEAD) | |
| VERSION="alpha-${COMMIT_HASH}" | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| sed -i '/#define RELEASE_VER_STR/,/TOSTRING(RELEASE_VER_FIX)/c\#define RELEASE_VER_STR "'"$VERSION"'"' src/version.h | |
| elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| INPUT_VERSION="${{ github.event.inputs.version }}" | |
| if [ -n "$INPUT_VERSION" ]; then | |
| VERSION="$INPUT_VERSION" | |
| if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "::error::Invalid version '$VERSION'. Expected SemVer like 1.2.3" >&2 | |
| exit 1 | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | |
| sed -i 's/#define RELEASE_VER_MAIN .*/#define RELEASE_VER_MAIN '"$MAJOR"'/' src/version.h | |
| sed -i 's/#define RELEASE_VER_SUB .*/#define RELEASE_VER_SUB '"$MINOR"'/' src/version.h | |
| sed -i 's/#define RELEASE_VER_FIX .*/#define RELEASE_VER_FIX '"$PATCH"'/' src/version.h | |
| else | |
| COMMIT_HASH=$(git rev-parse --short HEAD) | |
| VERSION="manual-${COMMIT_HASH}" | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| fi | |
| fi | |
| - name: Set Build Mode | |
| shell: bash | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.build_mode }}" ]; then | |
| BUILD_MODE="${{ github.event.inputs.build_mode }}" | |
| else | |
| BUILD_MODE="release" | |
| fi | |
| echo "BUILD_MODE=$BUILD_MODE" >> $GITHUB_ENV | |
| echo "Using BUILD_MODE=$BUILD_MODE" | |
| - name: Set CLANG_BIN | |
| shell: bash | |
| run: | | |
| CLANG_BIN=$(dirname "$(where clang-cl | head -n 1)") | |
| echo "CLANG_BIN=$CLANG_BIN" >> $GITHUB_ENV | |
| - name: Setup Xmake | |
| uses: xmake-io/github-action-setup-xmake@v1 | |
| with: | |
| xmake-version: '3.0.5' | |
| - name: Configure Xmake | |
| run: xmake f -m ${{ env.BUILD_MODE }} -a ${{ matrix.arch }} --toolchain=clang-cl --bin="${{ env.CLANG_BIN }}" --yes | |
| - name: Build Chrome++ | |
| shell: bash | |
| run: | | |
| if [ "${{ env.BUILD_MODE }}" == "debug" ]; then | |
| xmake -vD | |
| else | |
| xmake | |
| fi | |
| - name: Upload Build Artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: version-${{ matrix.arch }}${{ env.BUILD_MODE == 'debug' && '-debug' || '' }}-${{ env.VERSION }} | |
| path: build/${{ env.BUILD_MODE }}/* | |
| create_pr: | |
| needs: build | |
| runs-on: ubuntu-slim | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Git Configurations | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git checkout -b release | |
| - name: Update version.h | |
| run: | | |
| VERSION="${{ github.event.inputs.version }}" | |
| if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Invalid version '$VERSION'. Expected SemVer like 1.2.3" >&2 | |
| exit 1 | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | |
| sed -i 's/#define RELEASE_VER_MAIN .*/#define RELEASE_VER_MAIN '"$MAJOR"'/' src/version.h | |
| sed -i 's/#define RELEASE_VER_SUB .*/#define RELEASE_VER_SUB '"$MINOR"'/' src/version.h | |
| sed -i 's/#define RELEASE_VER_FIX .*/#define RELEASE_VER_FIX '"$PATCH"'/' src/version.h | |
| git add src/version.h | |
| git commit -m "build(release): bump version to $VERSION" | |
| git push origin release --force | |
| - name: Create Pull Request | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
| run: | | |
| gh pr create --base main --head release --title "build(release): bump version to ${{ github.event.inputs.version }}" --body "Bump version to ${{ github.event.inputs.version }}" | |
| - name: Output Run ID | |
| run: echo "RUN_ID=${{ github.run_id }}" >> $GITHUB_OUTPUT |