|
| 1 | +name: Build Chip |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + runs-on: ubuntu-22.04 |
| 10 | + name: Build chip |
| 11 | + steps: |
| 12 | + - name: Setup | Rust |
| 13 | + uses: actions-rs/toolchain@v1 |
| 14 | + with: |
| 15 | + default: true |
| 16 | + target: wasm32-unknown-unknown |
| 17 | + components: clippy, rustfmt |
| 18 | + toolchain: stable |
| 19 | + - name: Check out repository |
| 20 | + uses: actions/checkout@v3 |
| 21 | + - name: Build | Fmt Check |
| 22 | + run: cargo fmt -- --check |
| 23 | + - name: Build | Clippy |
| 24 | + run: cargo clippy --no-deps |
| 25 | + - name: Build | Compile |
| 26 | + run: cargo build --release |
| 27 | + - name: Build | Copy dist files |
| 28 | + run: | |
| 29 | + mkdir -p dist |
| 30 | + cp target/wasm32-unknown-unknown/release/chip_*.wasm dist/chip.wasm |
| 31 | + cp wokwi-chip.json dist/chip.json |
| 32 | + - name: 'Upload Artifacts' |
| 33 | + uses: actions/upload-artifact@v3 |
| 34 | + with: |
| 35 | + name: chip |
| 36 | + path: dist/* |
| 37 | + |
| 38 | + # The release job only runs when you push a tag starting with "v", e.g. v1.0.0 |
| 39 | + release: |
| 40 | + name: Release |
| 41 | + needs: build |
| 42 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - name: Download compiled chip |
| 46 | + uses: actions/download-artifact@v3 |
| 47 | + with: |
| 48 | + name: chip |
| 49 | + path: chip |
| 50 | + - name: Create chip.version.txt file |
| 51 | + run: echo "$ZIP_VERSION" > chip/chip.version.txt |
| 52 | + env: |
| 53 | + ZIP_VERSION: ${{ github.ref_name }} |
| 54 | + - name: Create a zip archive |
| 55 | + run: cd chip && zip -9 ../chip.zip chip.* |
| 56 | + - name: Upload release |
| 57 | + uses: ncipollo/release-action@v1 |
| 58 | + with: |
| 59 | + artifacts: chip.zip |
| 60 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + generateReleaseNotes: true |
0 commit comments