|
1 | | -name: CI |
| 1 | +name: CI & Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: [ "master" ] |
| 5 | + branches: [ "master", "main" ] |
6 | 6 | tags: |
7 | | - - 'v*' |
| 7 | + - '*' |
8 | 8 | pull_request: |
9 | | - branches: [ "master" ] |
| 9 | + branches: [ "master", "main" ] |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
10 | 13 |
|
11 | 14 | env: |
12 | 15 | CARGO_TERM_COLOR: always |
|
72 | 75 | # Ignoring fail under 100 for now as current codebase might not be 100% |
73 | 76 | run: cargo tarpaulin --workspace --out Xml |
74 | 77 |
|
75 | | - - name: Upload artifacts (if tag) |
76 | | - if: startsWith(github.ref, 'refs/tags/v') |
| 78 | + build-native: |
| 79 | + needs: build_and_test |
| 80 | + if: github.event_name == 'push' |
| 81 | + strategy: |
| 82 | + matrix: |
| 83 | + include: |
| 84 | + - os: ubuntu-latest |
| 85 | + target: x86_64-unknown-linux-gnu |
| 86 | + artifact_name: cdd-rust-x86_64-unknown-linux-gnu |
| 87 | + - os: macos-latest |
| 88 | + target: aarch64-apple-darwin |
| 89 | + artifact_name: cdd-rust-aarch64-apple-darwin |
| 90 | + runs-on: ${{ matrix.os }} |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v6 |
| 93 | + - name: Install Rust |
| 94 | + uses: dtolnay/rust-toolchain@stable |
| 95 | + with: |
| 96 | + targets: ${{ matrix.target }} |
| 97 | + - name: Build Native |
| 98 | + run: | |
| 99 | + cargo build --release -p cdd-cli --target ${{ matrix.target }} |
| 100 | + cp target/${{ matrix.target }}/release/cdd-rust ${{ matrix.artifact_name }} || cp target/release/cdd-rust ${{ matrix.artifact_name }} |
| 101 | + - name: Upload Artifact |
| 102 | + uses: actions/upload-artifact@v4 |
| 103 | + with: |
| 104 | + name: ${{ matrix.artifact_name }} |
| 105 | + path: ${{ matrix.artifact_name }} |
| 106 | + |
| 107 | + build-wasm: |
| 108 | + needs: build_and_test |
| 109 | + if: github.event_name == 'push' |
| 110 | + runs-on: ubuntu-latest |
| 111 | + steps: |
| 112 | + - uses: actions/checkout@v6 |
| 113 | + - name: Install Rust |
| 114 | + uses: dtolnay/rust-toolchain@stable |
| 115 | + with: |
| 116 | + targets: wasm32-wasip1 |
| 117 | + - name: Install binaryen |
| 118 | + run: | |
| 119 | + wget -qO- https://github.com/WebAssembly/binaryen/releases/download/version_129/binaryen-version_129-x86_64-linux.tar.gz | tar xvz |
| 120 | + echo "$PWD/binaryen-version_129/bin" >> $GITHUB_PATH |
| 121 | + - name: Build WASM |
| 122 | + run: | |
| 123 | + make build_wasm |
| 124 | + cp target/wasm32-wasip1/release/*.wasm cdd-rust.wasm || true |
| 125 | + # Optimize if present |
| 126 | + if [ -f "cdd-rust.wasm" ]; then |
| 127 | + wasm-opt -O3 cdd-rust.wasm -o cdd-rust.wasm || true |
| 128 | + fi |
| 129 | + - name: Upload Artifact |
| 130 | + uses: actions/upload-artifact@v4 |
| 131 | + with: |
| 132 | + name: cdd-rust.wasm |
| 133 | + path: cdd-rust.wasm |
| 134 | + |
| 135 | + release: |
| 136 | + needs: [build-native, build-wasm] |
| 137 | + if: github.event_name == 'push' |
| 138 | + runs-on: ubuntu-latest |
| 139 | + steps: |
| 140 | + - uses: actions/checkout@v6 |
| 141 | + - name: Update latest tag |
| 142 | + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' |
| 143 | + run: | |
| 144 | + git config user.name "github-actions" |
| 145 | + git config user.email "github-actions@github.com" |
| 146 | + git tag -f latest |
| 147 | + git push origin -f latest |
| 148 | + |
| 149 | + - name: Download Artifacts |
| 150 | + uses: actions/download-artifact@v4 |
| 151 | + with: |
| 152 | + path: artifacts |
| 153 | + merge-multiple: true |
| 154 | + |
| 155 | + - name: Release Artifacts |
77 | 156 | uses: softprops/action-gh-release@v2 |
78 | 157 | with: |
79 | | - files: | |
80 | | - target/release/cdd-rust |
| 158 | + tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }} |
| 159 | + files: artifacts/* |
| 160 | + prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }} |
0 commit comments