Skip to content

Update README.md

Update README.md #2

Workflow file for this run

name: Windows CD
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [windows-2022]
arch: [x64, x86]
runs-on: ${{ matrix.os }}
concurrency:
group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.os }}-${{ matrix.arch }}-Windows
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest
- name: Set xmake package cache path
run: echo "XMAKE_PKG_CACHEDIR=$(pwd)/xmake-cache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Retrieve xmake cache for packages
uses: actions/cache@v4
with:
path: xmake-cache
key: ${{ matrix.os }}-${{ matrix.arch }}
- name: Set release arch name
run: |
if ("${{ matrix.arch }}" -eq "x64") {
Write-Output "RELEASE_NAME=win64" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append
} else {
Write-Output "RELEASE_NAME=win32" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append
}
- name: Build
run: |
xmake f -v -a ${{ matrix.arch }} -y
xmake -vD -y
- name: Get target name
id: get_target_name
run: |
$targetName = (Select-String -Path xmake.lua -Pattern 'target\("(.+)"\)' | ForEach-Object { $_.Matches.Groups[1].Value })
echo "::set-output name=target_name::$targetName"
- name: Rename exe file
run: mv "build/windows/${{ matrix.arch }}/release/${{ steps.get_target_name.outputs.target_name }}.exe" "build/windows/${{ matrix.arch }}/release/${{ steps.get_target_name.outputs.target_name }}_${{ matrix.arch }}.exe"
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: exe-file-${{ matrix.arch }}
path: build/windows/${{ matrix.arch }}/release/${{ steps.get_target_name.outputs.target_name }}_${{ matrix.arch }}.exe
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure you fetch all history for all branches and tags
- name: Extract version
id: extract_version
run: |
VERSION=$(grep 'set_version' xmake.lua | cut -d'"' -f 2)
echo "::set-output name=version::$VERSION"
- name: Check if tag exists
id: check_tag
run: |
git fetch --tags
if git rev-parse ${{ steps.extract_version.outputs.version }} >/dev/null 2>&1; then
echo "Tag already exists"
else
echo "Tag does not exist. Continuing to next step."
echo "::set-output name=tag_exists::false"
fi
- name: Create Tag
id: create_tag
if: steps.check_tag.outputs.tag_exists == 'false'
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
git tag -a ${{ steps.extract_version.outputs.version }} -m "Release ${{ steps.extract_version.outputs.version }}"
git push origin ${{ steps.extract_version.outputs.version }}
- name: Generate Changelog
id: generate_changelog
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 --match "*.*.*" $(git rev-list --tags --skip=1 --max-count=1))
echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> $GITHUB_ENV
git log --no-merges --pretty="%h - %s (%an)<br />" $PREVIOUS_TAG..$VERSION > CHANGELOG.md
- name: Get target name
id: get_target_name
run: |
targetName=$(grep 'target' xmake.lua | cut -d'"' -f 2)
echo "::set-output name=target_name::$targetName"
- name: Download x64 artifact
uses: actions/download-artifact@v2
with:
name: exe-file-x64
- name: Download x86 artifact
uses: actions/download-artifact@v2
with:
name: exe-file-x86
- name: Display structure of downloaded files
run: ls -R
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
fail_on_unmatched_files: true
tag_name: ${{ steps.extract_version.outputs.version }}
name: Release ${{ steps.extract_version.outputs.version }}
body_path: CHANGELOG.md
files: |
${{ steps.get_target_name.outputs.target_name }}_x64.exe
${{ steps.get_target_name.outputs.target_name }}_x86.exe