feat(conda-launchers): switch to noarch metapackage #25
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: CICD | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request_target: | |
jobs: | |
ci_check: | |
name: Check | |
runs-on: ubuntu-latest | |
outputs: | |
should_build: ${{ steps.should_build.outputs.should_build }} | |
changed_dirs: ${{ steps.should_build.outputs.changed_dirs }} | |
steps: | |
- name: Checkout Source | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Changed Files | |
id: changed_files | |
uses: tj-actions/changed-files@v45 | |
with: | |
dir_names: true | |
dir_names_exclude_current_dir: true | |
dir_names_max_depth: '1' | |
- name: Should Build | |
id: should_build | |
env: | |
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }} | |
COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
IS_RELEASE_COMMIT: "${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'chore(main): release') }}" | |
shell: pwsh | |
run: | | |
if ($env:IS_RELEASE_COMMIT -eq 'true') { | |
$name = $env:COMMIT_MESSAGE -replace '(?s)chore.*release (\w+) v?.*', '$1' | |
echo "should_build=true" >> $env:GITHUB_OUTPUT | |
echo "changed_dirs=$name" >> $env:GITHUB_OUTPUT | |
} else { | |
$changed_dirs = $env:CHANGED_FILES -split '\r?\n' | |
Write-Host "Changed directories: $changed_dirs" | |
$changed_dirs = $changed_dirs | Where-Object { ` | |
-not $_.StartsWith('.') ` | |
-and (Test-Path -Path "$_/recipe.yaml") ` | |
} | |
$should_build = 'false' | |
if ($changed_dirs) { | |
$should_build = 'true' | |
} | |
$changed_dirs = $changed_dirs -join '\n' | |
# Write-Host "should_build: $should_build" | |
# Write-Host "changed_dirs: $changed_dirs" | |
echo "should_build=$should_build" >> $env:GITHUB_OUTPUT | |
echo "changed_dirs=$changed_dirs" >> $env:GITHUB_OUTPUT | |
} | |
ci_build: | |
name: Build | |
needs: ci_check | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- { target: win-64, os: windows-latest } | |
- { target: win-arm64, os: windows-latest } | |
- { target: linux-64, os: ubuntu-latest } | |
- { target: linux-aarch64, os: ubuntu-latest } | |
- { target: osx-64, os: macos-13 } | |
- { target: osx-arm64, os: macos-latest } | |
runs-on: ${{ matrix.os }} | |
if: needs.ci_check.outputs.should_build == 'true' | |
steps: | |
- name: Checkout Source | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
fetch-depth: 1 | |
- name: Setup Pixi | |
uses: prefix-dev/setup-pixi@v0.8.1 | |
with: | |
cache: true | |
- name: Run Build | |
env: | |
CHANGED_FILES: ${{ needs.ci_check.outputs.changed_dirs }} | |
shell: pwsh | |
run: | | |
$changed_dirs = $env:CHANGED_FILES -split '\n' | |
foreach ($dir in $changed_dirs) { | |
Write-Host "Building $dir..." | |
pixi run build build --recipe-dir $dir ` | |
--target-platform ${{ matrix.target }} ` | |
--log-style plain ` | |
--skip-existing all ` | |
-c conda-forge -c chawyehsu | |
} | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }}-builds | |
path: ./output/${{ matrix.target }}/*.conda | |
cd_release: | |
name: Release | |
needs: ci_build | |
runs-on: ubuntu-latest | |
if: "${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'chore(main): release') }}" | |
steps: | |
- name: Checkout Source | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
fetch-depth: 1 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: uploads | |
- name: Setup Pixi | |
uses: prefix-dev/setup-pixi@v0.8.1 | |
with: | |
cache: true | |
- name: Upload to Anaconda | |
env: | |
ANACONDA_OWNER: chawyehsu | |
ANACONDA_API_KEY: ${{ secrets.ANACONDA_API_KEY }} | |
COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
shell: pwsh | |
run: | # commit message format: chore(main): release pkg_name v1.2.3 | |
$name = $env:COMMIT_MESSAGE -replace '(?s)chore.*release (\w+) v?.*', '$1' | |
if ($name -eq '') { | |
Write-Error "Package name is not found in the commit message." | |
exit 1 | |
} | |
if (-not $env:ANACONDA_API_KEY -or $env:ANACONDA_API_KEY -eq '') { | |
Write-Error "ANACONDA_API_KEY is not set." | |
exit 1 | |
} | |
foreach ($file in Get-ChildItem -Path "./uploads/*/$name*.conda") { | |
Write-Host "Uploading $($file.Name)" | |
pixi run build upload anaconda "$file" --log-style plain | |
} |