fix codacy warnings #107
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |