-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (76 loc) · 2.54 KB
/
Copy pathrelease.yml
File metadata and controls
85 lines (76 loc) · 2.54 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
name: Release
on:
push:
branches: [main]
tags: ["v*"]
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --config Release
- name: Package
shell: bash
run: |
mkdir -p dist
VER="${GITHUB_REF_NAME:-dev}"
tar -czf "dist/onql-cpp-${VER}-${{ matrix.os }}.tar.gz" -C build .
tar -czf "dist/onql-cpp-${VER}-${{ matrix.os }}-headers.tar.gz" include
- uses: actions/upload-artifact@v4
with:
name: onql-cpp-${{ matrix.os }}
path: dist/*
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Resolve version
id: ver
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
V="${GITHUB_REF_NAME}"
elif [ -f VERSION ]; then
V="v$(cat VERSION | tr -d '[:space:]')"
else
echo "skip=true" >> "$GITHUB_OUTPUT"; exit 0
fi
echo "version=$V" >> "$GITHUB_OUTPUT"
- name: Check if tag already exists
id: gate
if: steps.ver.outputs.skip != 'true'
run: |
if git rev-parse "refs/tags/${{ steps.ver.outputs.version }}" >/dev/null 2>&1; then
echo "already=true" >> "$GITHUB_OUTPUT"
else
echo "already=false" >> "$GITHUB_OUTPUT"
fi
- name: Create tag
if: steps.ver.outputs.skip != 'true' && steps.gate.outputs.already == 'false' && !startsWith(github.ref, 'refs/tags/')
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.ver.outputs.version }}" -m "Release ${{ steps.ver.outputs.version }}"
git push origin "${{ steps.ver.outputs.version }}"
- name: Create GitHub release
if: steps.ver.outputs.skip != 'true' && steps.gate.outputs.already == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.ver.outputs.version }}
generate_release_notes: true
files: artifacts/**/*