Skip to content

Commit de95eff

Browse files
ci: create release from now on.
1 parent 10a0f3c commit de95eff

File tree

2 files changed

+67
-76
lines changed

2 files changed

+67
-76
lines changed
Lines changed: 63 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,96 @@
1-
name: CMake Multi-Platform CI
1+
name: Package
22

33
on:
44
push:
5-
branches: ["main", "master"]
6-
tags:
7-
- 'v*'
5+
branches: [main, master]
6+
tags: ["v*"]
87
pull_request:
9-
branches: ["main", "master"]
8+
branches: [main, master]
109

1110
jobs:
12-
build:
11+
package:
12+
name: Package for ${{ matrix.os }}
1313
runs-on: ${{ matrix.os }}
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
os: [ubuntu-latest, windows-latest]
18-
build_type: [Release]
19-
include:
20-
- os: windows-latest
21-
c_compiler: cl
22-
cpp_compiler: cl
23-
generator: "Visual Studio 17 2022"
24-
is_windows: true
25-
- os: ubuntu-latest
26-
c_compiler: gcc
27-
cpp_compiler: g++
28-
generator: "Unix Makefiles"
29-
is_windows: false
30-
- os: ubuntu-latest
31-
c_compiler: clang
32-
cpp_compiler: clang++
33-
generator: "Unix Makefiles"
34-
is_windows: false
17+
os: [ubuntu-22.04, windows-2022]
3518

3619
steps:
3720
- uses: actions/checkout@v4
3821
with:
3922
submodules: "recursive"
4023

41-
- name: Setup Linux Dependencies
42-
if: matrix.is_windows == false
24+
- name: Install dependencies (Ubuntu)
25+
if: runner.os == 'Linux'
4326
run: |
4427
sudo apt-get update
45-
sudo apt-get install -y build-essential cmake clang rpm
28+
sudo apt-get install -y build-essential cmake rpm dpkg
29+
timeout-minutes: 5
4630

47-
- name: Setup Windows Dependencies
48-
if: matrix.is_windows
31+
- name: Install NSIS (Windows)
32+
if: runner.os == 'Windows'
4933
run: |
5034
choco install nsis
35+
timeout-minutes: 5
5136

52-
- name: Configure CMake (Windows)
53-
if: matrix.is_windows
54-
shell: cmd
37+
- name: Configure CMake
5538
run: |
56-
cmake -B build ^
57-
-G "${{ matrix.generator }}" ^
58-
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ^
59-
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} ^
60-
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
39+
cmake -B build -DCMAKE_BUILD_TYPE=Release --log-level=VERBOSE
40+
timeout-minutes: 10
6141

62-
- name: Configure CMake (Linux)
63-
if: matrix.is_windows == false
64-
shell: bash
65-
run: |
66-
cmake -B build \
67-
-G "${{ matrix.generator }}" \
68-
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
69-
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
70-
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
71-
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
72-
-DCMAKE_CXX_FLAGS="-fPIC -fms-extensions" \
73-
-Dstrdup=_strdup
74-
75-
- name: Build (Windows)
76-
if: matrix.is_windows
77-
shell: cmd
78-
run: |
79-
cmake --build build --config ${{ matrix.build_type }} --parallel
80-
81-
- name: Build (Linux)
82-
if: matrix.is_windows == false
83-
shell: bash
42+
- name: Build
8443
run: |
85-
cmake --build build --config ${{ matrix.build_type }} --parallel
44+
cmake --build build --config Release --verbose
45+
timeout-minutes: 20
8646

87-
- name: Package (Windows)
88-
if: matrix.is_windows
89-
working-directory: build
90-
shell: cmd
47+
- name: Package (with libs)
9148
run: |
49+
cd build
9250
cpack -C applications
51+
timeout-minutes: 10
9352

94-
- name: Package (Linux)
95-
if: matrix.is_windows == false
96-
working-directory: build
97-
shell: bash
53+
- name: List generated packages (with libs)
9854
run: |
99-
cpack -C applications
55+
ls -la build/
56+
shell: bash
10057

101-
- name: Upload Packages
58+
- name: Upload artifacts (with libs)
10259
uses: actions/upload-artifact@v4
10360
with:
104-
name: packages-${{ matrix.os }}-${{ matrix.cpp_compiler }}
105-
path: build/Astra-CacheServer-*
61+
name: astra-cache-server-${{ matrix.os }}-with-libs
62+
path: |
63+
build/*.tar.gz
64+
build/*.zip
65+
build/*.deb
66+
build/*.rpm
67+
build/*.exe
68+
69+
release:
70+
name: Create Release
71+
needs: [package]
72+
if: startsWith(github.ref, 'refs/tags/v')
73+
runs-on: ubuntu-22.04
74+
permissions:
75+
contents: write
76+
steps:
77+
- name: Checkout code
78+
uses: actions/checkout@v4
79+
80+
- name: Download artifacts
81+
uses: actions/download-artifact@v4
82+
83+
- name: Display structure of downloaded files
84+
run: ls -R
85+
86+
- name: Create Release
87+
uses: softprops/action-gh-release@v1
88+
with:
89+
files: |
90+
astra-cache-server-*/*.tar.gz
91+
astra-cache-server-*/*.zip
92+
astra-cache-server-*/*.deb
93+
astra-cache-server-*/*.rpm
94+
astra-cache-server-*/*.exe
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.16)
2-
project(Astra VERSION 0.1.0.0 LANGUAGES CXX C) # 完整版本号:主.次.补丁.修订
2+
project(Astra VERSION 0.1.0.2 LANGUAGES CXX C) # 完整版本号:主.次.补丁.修订
33

44
# 添加生成目录到包含路径,确保代码能引用
55
include_directories("${PROJECT_BINARY_DIR}/core")
@@ -92,14 +92,14 @@ set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CM
9292
if(WIN32)
9393
# Windows平台生成NSIS安装包、TAR.GZ和ZIP
9494
set(CPACK_GENERATOR "NSIS;TGZ;ZIP")
95-
95+
9696
# NSIS特定配置
9797
set(CPACK_NSIS_DISPLAY_NAME "Astra Cache Server")
9898
set(CPACK_NSIS_PACKAGE_NAME "Astra Cache Server")
9999
set(CPACK_NSIS_CONTACT "support@astra.example.com")
100100
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
101101
set(CPACK_NSIS_MODIFY_PATH ON)
102-
102+
103103
# Windows服务安装
104104
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
105105
ExecWait '$INSTDIR\\\\bin\\\\Astra-CacheServer.exe install'
@@ -110,7 +110,7 @@ if(WIN32)
110110
else()
111111
# Linux平台生成DEB、TAR.GZ和ZIP
112112
set(CPACK_GENERATOR "DEB;TGZ;ZIP")
113-
113+
114114
# DEB特定配置
115115
set(CPACK_DEBIAN_PACKAGE_NAME "astra-cacheserver")
116116
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Astra Team <support@astra.example.com>")

0 commit comments

Comments
 (0)