name: Build on: release: types: [published] workflow_dispatch: # manual: build + package only (no version override, no upload) permissions: contents: write # so GITHUB_TOKEN can upload assets to the release jobs: build: name: ${{ matrix.archive }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - os: ubuntu-latest target: x86_64-unknown-linux-gnu binary: ccsm archive: ccsm-linux-amd64.tar.gz - os: macos-latest target: x86_64-apple-darwin binary: ccsm archive: ccsm-darwin-amd64.tar.gz - os: windows-latest target: x86_64-pc-windows-msvc binary: ccsm.exe archive: ccsm-windows-amd64.zip steps: - name: Checkout uses: actions/checkout@v7 - name: Set version from release tag if: github.event_name == 'release' run: | VERSION="${GITHUB_REF_NAME#v}" echo "CCSM_VERSION=$VERSION" >> "$GITHUB_ENV" - name: Install Rust toolchain (+ target) uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - name: Build release binary run: cargo build --release --target ${{ matrix.target }} - name: Package archive shell: bash run: | cd "target/${{ matrix.target }}/release" if [[ "${{ runner.os }}" == 'Windows' ]]; then powershell -NoProfile -Command "Compress-Archive -Path '${{ matrix.binary }}' -DestinationPath '${{ matrix.archive }}' -Force" else tar czf "${{ matrix.archive }}" "${{ matrix.binary }}" fi - name: Upload to GitHub release if: github.event_name == 'release' env: GH_TOKEN: ${{ github.token }} run: gh release upload "${{ github.event.release.tag_name }}" "target/${{ matrix.target }}/release/${{ matrix.archive }}" --clobber