-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (120 loc) · 4.42 KB
/
release.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
name: release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
branches:
- dev
workflow_dispatch:
permissions: write-all
jobs:
setup:
runs-on: ubuntu-latest
outputs:
build_type: ${{ steps.build.outputs.build_type }}
tag_name: ${{ steps.build.outputs.tag_name }}
steps:
- name: Define envs
run:
echo "CMAKE_BUILD_TYPE=Release" >> $GITHUB_ENV
- if: github.event_name == 'push'
run: |
echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Setup build type
id: build
run: |
echo "tag name: ${TAG_NAME}"
echo "build_type=${CMAKE_BUILD_TYPE}" >> $GITHUB_OUTPUT
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
build-artifacts:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: setup
strategy:
fail-fast: false
matrix:
os: [ debian-bullseye, fedora-41 ]
root: [ "with-root", "no-root" ]
include:
- os: debian-bullseye
static-libstdcxx: ON
- os: fedora-41
static-libstdcxx: OFF
name: ${{ matrix.os }}-${{ matrix.root }}
env:
CMAKE_GENERATOR: Ninja
container:
image: yanzhaowang/srs-env:${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'true'
- name: recover envs
run: |
echo "CMAKE_BUILD_TYPE=${{ needs.setup.outputs.build_type }}" >> $GITHUB_ENV
echo "TAG_NAME=${{ needs.setup.outputs.tag_name }}" >> $GITHUB_ENV
cd $GITHUB_WORKSPACE/..
echo "PARENT_DIR=$PWD" >> $GITHUB_ENV
if [[ ${{ matrix.root }} == "with-root" ]]; then export DISABLE_ROOT="OFF"; else export DISABLE_ROOT="ON"; fi
echo "DISABLE_ROOT=${DISABLE_ROOT}" >> $GITHUB_ENV
- name: install miniconda
run: |
mkdir -p ${PARENT_DIR}/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ${PARENT_DIR}/miniconda3/miniconda.sh
bash ${PARENT_DIR}/miniconda3/miniconda.sh -b -u -p ${PARENT_DIR}/miniconda3
rm -f ${PARENT_DIR}/miniconda3/miniconda.sh
source $PARENT_DIR/miniconda3/bin/activate
conda env create -f $GITHUB_WORKSPACE/environment.yml
- name: build
run: |
source $PARENT_DIR/miniconda3/bin/activate
conda activate srs
mkdir ${PARENT_DIR}/srs-install
cmake --preset static -DCMAKE_INSTALL_PREFIX=${PARENT_DIR}/srs-install -DBUILD_STATIC_STDCXX=${{ matrix.static-libstdcxx }} -DNO_ROOT=$DISABLE_ROOT
cmake --build ./build --target install -- -j2
cd ${{ env.PARENT_DIR }}
tar czf "srs-${{ matrix.os}}-x86-64-${{ env.TAG_NAME }}-${{ matrix.root }}.tar.gz" srs-install
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os}}-${{ env.TAG_NAME }}-${{ matrix.root }}
path: ${{ env.PARENT_DIR }}/srs-${{ matrix.os}}-x86-64-${{ env.TAG_NAME }}-${{ matrix.root }}.tar.gz
retention-days: 1
publish-release:
runs-on: ubuntu-latest
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.SRS_GH_TOKEN }}
defaults:
run:
shell: bash
permissions: write-all
needs: [ setup, build-artifacts ]
steps:
- uses: actions/checkout@v4
- name: envs
run: |
export TAG_NAME=${{ needs.setup.outputs.tag_name }}
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
cd ${GITHUB_WORKSPACE}/..
mkdir download-cache && cd download-cache
echo "DOWNLOAD_DIR=$PWD" >> $GITHUB_ENV
if [ $TAG_NAME == "dev" ]; then
echo "TITLE=\"Release of unstable dev branch\"" >> $GITHUB_ENV
echo "PRERELEASE=--prerelease" >> $GITHUB_ENV
else
echo "TITLE=\"Release of version $TAG_NAME\"" >> $GITHUB_ENV
echo "PRERELEASE=" >> $GITHUB_ENV
fi
- uses: actions/download-artifact@v4
id: artifacts-download
with:
path: ${{ env.DOWNLOAD_DIR }}
- name: clean old releases
continue-on-error: true
run: gh release delete ${{ env.TAG_NAME }} || true
- name: create release
run: |
gh release create ${{ env.TAG_NAME }} ${{ env.PRERELEASE }} --generate-notes --title ${{ env.TITLE }} --target $GITHUB_SHA ${{ steps.artifacts-download.outputs.download-path}}/*/*.tar.gz