name: Build on: release: types: [published] jobs: build: runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - target: x86_64-unknown-linux-gnu binary: ccsm archive: ccsm-linux-amd64.tar.gz - target: x86_64-apple-darwin binary: ccsm archive: ccsm-darwin-amd64.tar.gz - target: x86_64-pc-windows-gnu binary: ccsm.exe archive: ccsm-windows-amd64.zip steps: - uses: actions/checkout@v4 - name: Set version run: | VERSION="${{ github.event.release.tag_name }}" VERSION="${VERSION#v}" echo "CCSM_VERSION=$VERSION" >> "$GITHUB_ENV" - name: Install Rust run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" - name: Install Rust targets run: | rustup target add ${{ matrix.target }} - name: Build (Linux) if: matrix.target == 'x86_64-unknown-linux-gnu' run: cargo build --release --target ${{ matrix.target }} - name: Install Zig if: matrix.target != 'x86_64-unknown-linux-gnu' run: | curl -L -o zig.tar.xz https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz tar xf zig.tar.xz echo "$PWD/zig-linux-x86_64-0.13.0" >> "$GITHUB_PATH" - name: Install cargo-zigbuild if: matrix.target != 'x86_64-unknown-linux-gnu' run: cargo install cargo-zigbuild - name: Build with zigbuild if: matrix.target != 'x86_64-unknown-linux-gnu' run: cargo zigbuild --release --target ${{ matrix.target }} - name: Package run: | cd "target/${{ matrix.target }}/release" if [[ "${{ matrix.target }}" == *-windows-* ]]; then zip "${{ matrix.archive }}" "${{ matrix.binary }}" else tar czf "${{ matrix.archive }}" "${{ matrix.binary }}" fi - name: Upload to release run: | curl --fail -X POST \ -H "Authorization: Bearer ${{ secrets.GITEA_TOKEN }}" \ -H "Content-Type: application/octet-stream" \ --data-binary @"target/${{ matrix.target }}/release/${{ matrix.archive }}" \ "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets?name=${{ matrix.archive }}"