-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (124 loc) · 4.97 KB
/
windows.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Windows CI/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: Run tests
run: |
xmake test -v
- 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