diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 593674a..8316bd8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,16 +1,13 @@ -name: CI +name: Release crate on: - push: - pull_request: + release: + types: [published] jobs: - test: - name: Build and test - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, Windows] + release: + name: Publish to crates.io and create GitHub Release + runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 @@ -28,3 +25,52 @@ jobs: - name: Build and test run: cargo test --workspace --verbose + + - name: Install cargo-edit and set crate version + id: set_version + run: | + cargo install cargo-edit --locked --force + TAG="${{ github.event.release.tag_name }}" + VERSION="${TAG#v}" + cargo set-version "$VERSION" --workspace + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Configure Cargo registries (crates.io default + add Gitea) + shell: bash + env: + TOKEN: ${{ secrets.CARGO_GITEA_TOKEN }} + GITEA_BASE_URL: https://git.heiserer.de + REGISTRY_OWNER: ${{ github.repository_owner }} + run: | + mkdir -p ~/.cargo + # crates.io stays default + cat > ~/.cargo/config.toml <<'EOF' + [registry] + default = "crates-io" + EOF + + # Add Gitea as extra registry (sparse index recommended) + { + echo "[registries.gitea]" + echo "index = \"sparse+${GITEA_BASE_URL}/api/packages/${REGISTRY_OWNER}/cargo/\"" + } >> ~/.cargo/config.toml + + # Auth for Gitea registry + umask 077 + cat > ~/.cargo/credentials.toml <