Merge pull request #287 from khaledhosny/ci-updates #190
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: Build | |
on: | |
push: | |
branches: [main] | |
tags: ["v*.*.*"] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install Python Dependencies | |
run: pip install --upgrade meson==0.60.2 ninja | |
- name: MSVC Setup | |
if: matrix.os == 'windows-latest' | |
uses: ilammy/msvc-dev-cmd@v1 | |
- name: Meson Setup | |
run: meson --wrap-mode=forcefallback --buildtype=release --strip -Ddebug=true --prefix="${{ github.workspace }}/dist" build | |
- name: Build | |
run: ninja -C build | |
- name: Test | |
run: ninja -C build test | |
- name: Install | |
shell: bash | |
run: | | |
ninja -C build install | |
export VERSION=$(grep -m1 -o "version: '.*.'" meson.build | sed "s/version: '\(.*.\)'/\1/") | |
echo "ots_version=$VERSION" >> $GITHUB_ENV | |
mv -v dist/bin ots-$VERSION-${{ runner.os }} | |
- name: Archive | |
uses: thedoctor0/zip-release@master | |
with: | |
path: ots-${{ env.ots_version }}-${{ runner.os }} | |
filename: ots-${{ env.ots_version }}-${{ runner.os }}.zip | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ots-${{ env.ots_version }}-${{ runner.os }} | |
path: ots-*.zip | |
if-no-files-found: error | |
- name: Make Dist Tarball | |
if: matrix.os == 'ubuntu-latest' | |
run: meson dist -C build --no-tests | |
- name: Upload Dist Tarball | |
if: matrix.os == 'ubuntu-latest' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ots-${{ env.ots_version }} | |
path: build/meson-dist/ots-*.tar.xz | |
if-no-files-found: error | |
deploy: | |
if: github.ref_type == 'tag' | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifacts from build jobs | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
- name: Extract release notes from annotated tag message | |
run: | | |
# GH checkout action doesn't preserve tag annotations, we must fetch them | |
# https://github.com/actions/checkout/issues/290 | |
git fetch --tags --force | |
echo "$(git tag -l --format='%(contents:body)' ${{ github.ref_name }})" > "${{ runner.temp }}/release_body.md" | |
echo "release_name=$(git tag -l --format='%(contents:subject)' ${{ github.ref_name }})" >> $GITHUB_ENV | |
- name: Publish | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ env.release_name }} | |
body_path: ${{ runner.temp }}/release_body.md | |
fail_on_unmatched_files: true | |
files: | | |
dist/*/* |