-
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (117 loc) · 4.19 KB
/
Copy pathrelease.yml
File metadata and controls
140 lines (117 loc) · 4.19 KB
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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build-and-package:
strategy:
matrix:
include:
- os: ubuntu-latest
- os: windows-latest
- os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up CMake
uses: lukka/get-cmake@v3.29.0
with:
cmake-version: '3.25.x'
- name: Configure CMake
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SLICK_SOCKET_TESTING=OFF -DBUILD_SLICK_SOCKET_EXAMPLES=OFF
- name: Build
run: |
cmake --build build --config Release
- name: Create Distribution (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
mkdir -p dist
xcopy /E /I include dist\include
mkdir dist\lib
if (Test-Path build\lib\Release\slick-socket.lib) { copy build\lib\Release\slick-socket.lib dist\lib\ }
- name: Create Distribution (Linux/macOS)
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
mkdir -p dist
cp -r include dist/
- name: Create Archive (Windows)
if: runner.os == 'Windows'
run: |
cd dist
cmake -E tar "cfv" "${{ github.workspace }}/slick-socket-Windows-${{ github.ref_name }}.zip" --format=zip .
- name: Create Archive (Linux)
if: runner.os == 'Linux'
run: |
cd dist
cmake -E tar "cfzv" "${{ github.workspace }}/slick-socket-Linux-${{ github.ref_name }}.tar.gz" .
- name: Create Archive (macOS)
if: runner.os == 'macOS'
run: |
cd dist
cmake -E tar "cfzv" "${{ github.workspace }}/slick-socket-macOS-${{ github.ref_name }}.tar.gz" .
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: slick-socket-${{ runner.os }}-${{ github.ref_name }}
path: slick-socket-*
retention-days: 30
extract-changelog:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
changelog: ${{ steps.changelog.outputs.CHANGELOG_CONTENT }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Extract changelog for this version
id: changelog
run: |
if [ -f CHANGELOG ]; then
# Extract the section for this version from CHANGELOG
VERSION="${{ github.ref_name }}"
# Remove any suffix after the version (e.g., -test, -rc1)
VERSION_CLEAN=$(echo "$VERSION" | sed 's/-.*$//')
# Escape dots in version for regex
VERSION_ESCAPED=$(echo "$VERSION_CLEAN" | sed 's/\./\\./g')
# Use awk to extract content: start at version header (format: v1.5.2 - [date]), stop at next version header
CHANGES=$(awk "BEGIN{p=0} /^#$VERSION_ESCAPED/{p=1;next} /^#/{p=0} p" CHANGELOG | sed '/^$/d')
if [ -z "$CHANGES" ]; then
echo "CHANGELOG_CONTENT=No changelog entry found for this version." >> $GITHUB_OUTPUT
else
# Escape newlines for GitHub output
echo "CHANGELOG_CONTENT<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
else
echo "CHANGELOG_CONTENT=CHANGELOG not found." >> $GITHUB_OUTPUT
fi
create-release:
runs-on: ubuntu-latest
needs: [extract-changelog, build-and-package]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ github.ref_name }}
body: |
## Changes
${{ needs.extract-changelog.outputs.changelog }}
draft: true
prerelease: false
generate_release_notes: false
files: |
artifacts/**/*.zip
artifacts/**/*.tar.gz