name: release on: push: tags: - '[0-9]+.[0-9]+.[0-9]+' permissions: contents: write jobs: create-release: name: create-release runs-on: ubuntu-latest outputs: sctd_version: ${{ env.SCTD_VERSION }} steps: - uses: actions/checkout@v4 - name: Get the release version from the tag shell: bash run: echo "SCTD_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV - name: Show the version run: | echo "version is: $SCTD_VERSION" - name: Check that tag version and Cargo.toml version are the same shell: bash run: | if ! grep -q "version = \"$SCTD_VERSION\"" Cargo.toml; then echo "version does not match Cargo.toml" >&2 exit 1 fi - name: Create GitHub release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh release create ${{ env.SCTD_VERSION }} --draft --verify-tag --title ${{ env.SCTD_VERSION }} build-release: name: build-release needs: ['create-release'] runs-on: ${{ matrix.os }} strategy: matrix: build: [linux, macos] include: - build: linux os: ubuntu-latest rust: stable target: x86_64-unknown-linux-gnu - build: macos os: macos-latest rust: stable target: x86_64-apple-darwin steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install packages (Linux) if: matrix.build == 'linux' run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ libx11-dev \ libxrandr-dev - name: Install Rust uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} - name: Build release binary run: cargo build --verbose --release --target ${{ matrix.target }} - name: Strip release binary (linux and macos) if: matrix.build == 'linux' || matrix.build == 'macos' run: strip "target/${{ matrix.target }}/release/sctd" - name: Build archive shell: bash run: | staging="sctd-${{ needs.create-release.outputs.sctd_version }}-${{ matrix.target }}" mkdir -p "$staging" cp "target/${{ matrix.target }}/release/sctd" "$staging/" cp README.md LICENSE "$staging/" tar czf "$staging.tar.gz" "$staging" shasum -a 256 "$staging.tar.gz" > "$staging.tar.gz.sha256" echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV echo "ASSET_SUM=$staging.tar.gz.sha256" >> $GITHUB_ENV - name: Upload release archive env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh release upload ${{ needs.create-release.outputs.sctd_version }} ${{ env.ASSET }} ${{ env.ASSET_SUM }}