Skip to content

Fix hang when using --exec flag in Nix sandboxed builds #112

Fix hang when using --exec flag in Nix sandboxed builds

Fix hang when using --exec flag in Nix sandboxed builds #112

name: Build and Release
on: push
jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
# - windows-latest
include:
- os: ubuntu-latest
image: ubuntu:latest
- os: macos-latest
image: macos-latest
#- os: windows-latest
#image: windows-latest
steps:
- name: Set dummy ACTIONS_RUNTIME_TOKEN and ACTIONS_RUNTIME_URL for act
if: ${{ env.ACT }}
run: |
echo "ACTIONS_RUNTIME_TOKEN=dummy_token" >> $GITHUB_ENV
echo "ACTIONS_RUNTIME_URL=https://dummy_url" >> $GITHUB_ENV
# - name: Install GCC on Ubuntu
# if: matrix.os == 'ubuntu-latest' && ${{env.ACT}}
# run: |
# apt-get update
# apt-get install -y gcc
# - name: Install GCC on macOS
# if: matrix.os == 'macos-latest' && ${{ env.ACT }}
# run: |
# brew install gcc
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Build on Linux
if: matrix.os == 'ubuntu-latest'
run: |
cmake -B build/
cmake --build build/
mkdir -p ${{ matrix.os }}
cp build/await ${{ matrix.os }}/
cp build/await.fish ${{ matrix.os }}/
cp build/await.bash ${{ matrix.os }}/
cp build/await.zsh ${{ matrix.os }}/
# Copy binary to project root for tests
cp build/await ./await
- name: Build on macOS (arm64)
if: matrix.os == 'macos-latest'
run: |
cmake -B build-arm64/ -DCMAKE_OSX_ARCHITECTURES=arm64
cmake --build build-arm64/
mkdir -p macos-latest-arm64
cp build-arm64/await macos-latest-arm64/
cp build-arm64/await.fish macos-latest-arm64/
cp build-arm64/await.bash macos-latest-arm64/
cp build-arm64/await.zsh macos-latest-arm64/
- name: Build on macOS (x86_64)
if: matrix.os == 'macos-latest'
run: |
cmake -B build-x86_64/ -DCMAKE_OSX_ARCHITECTURES=x86_64
cmake --build build-x86_64/
mkdir -p macos-latest-x86_64
cp build-x86_64/await macos-latest-x86_64/
cp build-x86_64/await.fish macos-latest-x86_64/
cp build-x86_64/await.bash macos-latest-x86_64/
cp build-x86_64/await.zsh macos-latest-x86_64/
# Copy x86_64 binary to project root for tests on macOS
cp build-x86_64/await ./await
- name: Install test dependencies
working-directory: tests
run: |
pip install -e .
pip install pytest pytest-timeout
- name: Run tests
working-directory: tests
run: |
pytest test_await.py -v
- name: Tree
if: matrix.os == 'ubuntu-latest'
run: tree
- uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-latest'
with:
name: await-${{ matrix.os }}
path: ${{ matrix.os }}
- uses: actions/upload-artifact@v4
if: matrix.os == 'macos-latest'
with:
name: await-macos-latest-arm64
path: macos-latest-arm64
- uses: actions/upload-artifact@v4
if: matrix.os == 'macos-latest'
with:
name: await-macos-latest-x86_64
path: macos-latest-x86_64
release:
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch all history and tags for release notes generation
- name: Build await to get version
run: |
cmake -B build/
cmake --build build/
- name: Get version from await CLI
id: get_version
run: |
VERSION=$(./build/await --version)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Generate Release Notes
id: release_notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
# Get all tags sorted by version
PREV_TAG=$(git tag -l --sort=-v:refname | grep -v "^${VERSION}$" | head -n1)
if [ -z "$PREV_TAG" ]; then
echo "No previous tag found, using initial commit"
PREV_TAG=$(git rev-list --max-parents=0 HEAD)
fi
echo "Generating release notes from $PREV_TAG to $VERSION"
# Generate release notes from commits
RELEASE_NOTES="## Release $VERSION"
RELEASE_NOTES="${RELEASE_NOTES}\n\n### Changes since ${PREV_TAG}\n"
# Get commit messages, excluding merge commits and version bumps
COMMITS=$(git log ${PREV_TAG}..HEAD --oneline --no-merges --pretty=format:"- %s" | grep -v "^- Bump version")
if [ -z "$COMMITS" ]; then
RELEASE_NOTES="${RELEASE_NOTES}\n- Minor updates and improvements"
else
RELEASE_NOTES="${RELEASE_NOTES}\n${COMMITS}"
fi
# Save to file for multi-line handling
echo -e "$RELEASE_NOTES" > release_notes.md
# Also output for logging
echo "Release notes:"
cat release_notes.md
- name: Check if Release Exists
id: check_release
run: |
gh release view ${{ steps.get_version.outputs.VERSION }} || echo "Release does not exist"
- name: Create or Update Release
id: create_update_release
if: steps.check_release.outputs.exists == 'false'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: ${{ steps.get_version.outputs.VERSION }}
body_path: release_notes.md
draft: false
prerelease: false
- name: Update Release Archives
if: steps.check_release.outputs.exists == 'true'
run: |
gh release upload ${{ steps.get_version.outputs.VERSION }} archives/* --clobber
- name: Download Artifact
uses: actions/download-artifact@v4
- name: Create Archives
run: |
mkdir -p archives
tree
cd await-macos-latest-arm64 && tar -czvf ../archives/await-${{ steps.get_version.outputs.VERSION }}-aarch64-apple-darwin.tar.gz * && cd ..
cd await-macos-latest-x86_64 && tar -czvf ../archives/await-${{ steps.get_version.outputs.VERSION }}-x86_64-apple-darwin.tar.gz * && cd ..
cd await-ubuntu-latest && tar -czvf ../archives/await-${{ steps.get_version.outputs.VERSION }}-x86_64-unknown-linux-gnu.tar.gz * && cd ..
tree
- name: Upload Release Artifacts
uses: softprops/action-gh-release@v1
with:
files: archives/*
tag_name: ${{ steps.get_version.outputs.VERSION }}
body_path: release_notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}