From 06b730274de06c0d720a1f204ccd1ebd70bd59ce Mon Sep 17 00:00:00 2001 From: Sam Nystrom Date: Wed, 20 Mar 2024 20:47:08 -0400 Subject: [PATCH] ci: use release-please to detect releases --- .github/workflows/ci.yml | 44 ---------------------------- .github/workflows/release-please.yml | 21 +++++++++++++ 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c508b2..d42734b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,47 +40,3 @@ jobs: cache-on-failure: true - name: Run tests run: cargo test - - check-published-version: - name: Check published version - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' - needs: - - Check - - Test - - steps: - - name: Check out repository - uses: actions/checkout@v4 - - name: Install gojq - run: sudo apt-get install gojq - - name: 'Check if crate ${{ inputs.crate }} is published' - run: | - set -euxo pipefail - url="https://raw.githubusercontent.com/rust-lang/crates.io-index/master/ca/tp/catppuccin-egui" - published="$(curl -fsSL "$url" | gojq -sr 'map(.vers) | sort | .[-1]')" - manifest="$(awk -F \" '/version = / { print $2 }' Cargo.toml)" - - if [ "$manifest" = "$published" ]; then - echo 'new_version=no' >> $GITHUB_OUTPUT - else - echo 'new_version=yes' >> $GITHUB_OUTPUT - fi - - Publish: - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' && needs.check-published-version.outputs.new_version == 'yes' - environment: crates.io - needs: - - check-published-version - - steps: - - name: Check out repository - uses: actions/checkout@v4 - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - name: Publish crates - run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 8c8741e..13cc471 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,8 +7,29 @@ on: jobs: release-please: runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} steps: - uses: google-github-actions/release-please-action@v3 + id: release with: release-type: rust package-name: catppuccin-egui + + Publish: + needs: + - release-please + if: needs.release-please.outputs.release_created + runs-on: ubuntu-latest + environment: crates.io + + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Publish crates + run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}