final touches #44
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 recipes | |
on: | |
push: | |
branches: | |
- 'emscripten-3.1.58' | |
paths: | |
- 'recipes/**' | |
pull_request: | |
paths: | |
- 'recipes/**' | |
jobs: | |
build_recipes: | |
runs-on: ubuntu-latest | |
env: | |
TARGET_PLATFORM: emscripten-wasm32 | |
GITHUB_OWNER: "emscripten-forge" | |
strategy: | |
fail-fast: false | |
steps: | |
################################################################ | |
# SETUP | |
################################################################ | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Maximize build space | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /opt/ghc | |
sudo rm -rf "/usr/local/share/boost" | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
- name: Delete fortran | |
run: sudo apt-get remove gfortran -y | |
################################################################ | |
# CONFIG | |
################################################################ | |
- name: Global config | |
shell: bash -el {0} | |
run: git config --global advice.detachedHead false | |
################################################################ | |
# MAMBA | |
################################################################ | |
- name: Install micromamba | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
micromamba-version: '1.5.8-0' | |
environment-file: ci_env.yml | |
environment-name: ci | |
init-shell: bash | |
cache-environment: true | |
post-cleanup: 'all' | |
################################################################ | |
# POST ENV INSTALL CONFIG | |
################################################################ | |
- name: Post env install config | |
shell: bash -el {0} | |
run: | | |
cp $GITHUB_WORKSPACE/.github/workflows/.condarc $HOME | |
cp $GITHUB_WORKSPACE/conda_build_config.yaml $HOME | |
################################################################ | |
# PUSH | |
################################################################ | |
- name: Build recipes with changes PUSH | |
shell: bash -el {0} | |
if: github.event_name == 'push' | |
run: | | |
python -m emci build changed $GITHUB_WORKSPACE/ origin/emscripten-3.1.58~1 origin/emscripten-3.1.58 | |
################################################################ | |
# PULL_REQUEST | |
################################################################ | |
- name: Build recipes with changes PULL_REQUEST | |
shell: bash -el {0} | |
if: github.event_name == 'pull_request' | |
run: | | |
python -m emci build changed $GITHUB_WORKSPACE/ origin/emscripten-3.1.58 HEAD | |
################################################################ | |
# UPLOAD | |
################################################################ | |
- name: Upload packages to Quetz | |
if: (github.event_name == 'push' && github.repository == 'emscripten-forge/recipes') | |
shell: bash -l {0} | |
env: | |
QUETZ_API_KEY: ${{ secrets.QUETZ_API_KEY }} | |
run: | | |
overall_success=true | |
# Loop over {emscripten-wasm32, linux-64, noarch} | |
for platform in emscripten-wasm32 linux-64 noarch; do | |
if [ -d "${GITHUB_WORKSPACE}/output/${platform}" ]; then | |
cd "${GITHUB_WORKSPACE}/output/${platform}" | |
files=$(ls *.tar.bz2 2> /dev/null) | |
if [ -n "$files" ]; then | |
for package in $files; do | |
echo "Uploading ${package} for ${platform}" | |
FILE_SHA256=$(sha256sum "${package}" | awk '{ print $1 }') | |
CURL_CMD=( | |
curl -H "X-API-Key: ${QUETZ_API_KEY}" -X POST | |
"https://beta.mamba.pm/api/channels/emscripten-forge/upload/${package}?sha256=${FILE_SHA256}&force=false" | |
--data-binary "@${package}" | |
-o response_body.txt | |
-w "%{http_code}" | |
-s | |
) | |
HTTP_STATUS=$( "${CURL_CMD[@]}" ) | |
RESPONSE=$(<response_body.txt) | |
# Check the HTTP status code and log appropriate message | |
if [[ "$HTTP_STATUS" -eq 201 ]]; then | |
echo "Upload succeeded for ${package} on ${platform}" | |
else | |
echo "Error: Upload failed with HTTP status $HTTP_STATUS" | |
echo "Response Body: $RESPONSE" | |
overall_success=false | |
fi | |
rm -f response_body.txt | |
done | |
fi | |
fi | |
done | |
# Check if all uploads were successful | |
if [ "$overall_success" = false ]; then | |
echo "One or more uploads failed" | |
exit 1 | |
else | |
echo "All uploads completed successfully" | |
fi |