-
Notifications
You must be signed in to change notification settings - Fork 1
132 lines (118 loc) · 4.08 KB
/
build.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
name: Build
env:
VERSION: v0.0.0
ZIP_SHA256: ""
EXE_SHA256: ""
PDB_SHA256: ""
on:
push:
paths:
- "**.cpp"
- "**.cc"
- "**.cxx"
- "**.c"
- "**.hpp"
- "**.hh"
- "**.hxx"
- "**.h"
- ".github/workflows/build.yml"
- "**/xmake.lua"
pull_request:
release:
types:
- created
workflow_dispatch:
jobs:
build:
name: Build
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup XMake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest
- name: Cache XMake
uses: actions/cache@v3
with:
path: |
~/AppData/Local/.xmake
./.xmake
key: ${{ runner.os }}-xmake-${{ github.sha }}
restore-keys: |
${{ runner.os }}-xmake-
- name: Update XMake Repository
run: xmake repo -u
- name: Get Release Version Tag
if: github.event_name == 'release'
run: echo "VERSION=${{ github.ref_name }}" >> $env:GITHUB_ENV
- name: Get Previous Tag
if: github.event_name != 'release'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: "v0.0.0"
- name: Set Pseudo Version
if: github.event_name != 'release'
run: |
$date = (Get-Date -Format "yyyyMMddHHmmss")
$commit = git rev-parse --short HEAD
$previous_tag = "${{ steps.previoustag.outputs.tag }}"
echo "VERSION=$previous_tag-$date-$commit" >> $env:GITHUB_ENV
- name: Build PeEditor
run: |
xmake f -p windows -m release -a x64 --ccache=n -y
xmake -w -y
- name: Prepare Artifacts
run: |
mkdir artifacts
cp build/windows/x64/release/PeEditor.exe artifacts
cp build/windows/x64/release/PeEditor.pdb artifacts
mv artifacts peeditor-${{ env.VERSION }}-windows-amd64
mkdir artifacts
mv peeditor-${{ env.VERSION }}-windows-amd64 artifacts/
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: peeditor-${{ env.VERSION }}-windows-amd64
path: artifacts
upload-to-release:
name: Upload to Release
needs:
- build
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- name: Get Version
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Compress Artifacts
id: compress
run: |
mv peeditor-${{ env.VERSION }}-windows-amd64 artifacts
mv artifacts/peeditor-${{ env.VERSION }}-windows-amd64 .
cd peeditor-${{ env.VERSION }}-windows-amd64
zip -r ../peeditor-${{ env.VERSION }}-windows-amd64.zip *
cd ..
echo "ZIP_SHA256=$(sha256sum peeditor-${{ env.VERSION }}-windows-amd64.zip | cut -d ' ' -f 1)" >> $GITHUB_ENV
echo "EXE_SHA256=$(sha256sum peeditor-${{ env.VERSION }}-windows-amd64/PeEditor.exe | cut -d ' ' -f 1)" >> $GITHUB_ENV
echo "PDB_SHA256=$(sha256sum peeditor-${{ env.VERSION }}-windows-amd64/PeEditor.pdb | cut -d ' ' -f 1)" >> $GITHUB_ENV
shell: bash
- name: Upload Release Assets
uses: softprops/action-gh-release@v1
with:
append_body: true
files: |
peeditor-${{ env.VERSION }}-windows-amd64.zip
peeditor-${{ env.VERSION }}-windows-amd64/PeEditor.exe
peeditor-${{ env.VERSION }}-windows-amd64/PeEditor.pdb
body: |
---
| File | SHA256 |
| :-------------------------------------------- | :-------------------- |
| peeditor-${{ env.VERSION }}-windows-amd64.zip | ${{ env.ZIP_SHA256 }} |
| PeEditor.exe | ${{ env.EXE_SHA256 }} |
| PeEditor.pdb | ${{ env.PDB_SHA256 }} |