Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use release-please to detect releases #36

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,50 +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

outputs:
new_version: ${{ steps.last.outputs.new_version }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install gojq
run: sudo apt-get install gojq
- name: 'Check if crate catppuccin-egui is published'
id: last
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 }}
21 changes: 21 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}