feat: add build command #119
This file contains hidden or 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
| on: | |
| pull_request: {} | |
| push: | |
| # Sequence of patterns matched against refs/tags | |
| tags: | |
| - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 | |
| name: Release | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # a list of all the targets | |
| include: | |
| - TARGET: x86_64-unknown-linux-musl # Using MUSL for Linux | |
| OS: ubuntu-24.04 | |
| - TARGET: x86_64-apple-darwin # tested on a mac | |
| OS: macos-15 | |
| - TARGET: aarch64-apple-darwin | |
| OS: macos-15 | |
| name: Create Release ${{ github.event_name == 'pull_request' && '(dry-run)' }} | |
| runs-on: ${{ matrix.OS }} | |
| env: | |
| TARGET: ${{ matrix.TARGET }} | |
| OS: ${{ matrix.OS }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
| - name: Cargo cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ./target | |
| key: build-cargo-registry-${{matrix.TARGET}} | |
| - uses: mlugg/setup-zig@7dccf5e6d09267c55f815f2db29495f30ba2ebca | |
| - name: Install cargo-zigbuild | |
| run: cargo install cargo-zigbuild | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| target: $TARGET | |
| - name: Generate the artifacts | |
| run: | | |
| if [[ $TARGET == *-linux-musl ]]; then | |
| cargo zigbuild --release --target $TARGET | |
| else | |
| cargo build --release --target $TARGET | |
| fi | |
| - name: Move files | |
| run: | | |
| mkdir -p ./artifacts | |
| mv ./target/$TARGET/release/molnctl ./artifacts/molnctl-$TARGET | |
| - name: Create Release | |
| if: github.event_name == 'push' | |
| uses: softprops/action-gh-release@3198ee18f814cdf787321b4a32a26ddbf37acc52 # v2.0.3 | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| name: Release ${{ github.ref_name }} | |
| draft: true | |
| prerelease: false | |
| generate_release_notes: true | |
| files: "artifacts/*" |