diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 138fe56..e4e9764 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,8 @@ on: release: types: [published] +# Publishing a release again retries it: each job skips a version its registry already has. + jobs: publish-crates: name: Publish to crates.io @@ -11,10 +13,20 @@ jobs: steps: - uses: actions/checkout@v7 + # cargo publish builds the crate before uploading it, and Tauri needs these on Linux. + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libglib2.0-dev + - uses: dtolnay/rust-toolchain@stable - name: Publish - run: cargo publish + run: | + version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') + if curl -sf -A "tauri-plugin-aptabase release" "https://crates.io/api/v1/crates/tauri-plugin-aptabase/$version" > /dev/null; then + echo "tauri-plugin-aptabase $version is already on crates.io" + else + cargo publish + fi env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} @@ -37,4 +49,11 @@ jobs: - run: npm install - - run: npm publish \ No newline at end of file + - name: Publish + run: | + version=$(node -p "require('./package.json').version") + if [ "$(npm view "@aptabase/tauri@$version" version 2>/dev/null)" = "$version" ]; then + echo "@aptabase/tauri $version is already on npm" + else + npm publish + fi