|
1 | 1 | # Release the visualci CLI: static binaries for Linux (musl) and macOS, attached to a GitHub release v<version>; and |
2 | | -# publish the snapshot-diff crate (crates/snapshot-diff) to crates.io when its version isn't there yet. |
| 2 | +# publish the snapshot-diff crate (crates/snapshot-diff) to crates.io when its version isn't there yet (and, once their |
| 3 | +# Cargo.toml files drop `publish = false`, envschema-derive and envschema). |
3 | 4 | # A release happens by itself once CI passes on main with a workspace version (Cargo.toml) that has no release yet, so |
4 | 5 | # a version bump is all it takes and the docs never describe a CLI nobody can download. The cli-version job in ci.yml |
5 | 6 | # fails when the CLI changed since its last release without a bump. Pushing a v* tag by hand still works too. |
@@ -128,3 +129,48 @@ jobs: |
128 | 129 | env: |
129 | 130 | CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |
130 | 131 | run: cargo publish --locked -p snapshot-diff |
| 132 | + |
| 133 | + # envschema-derive and envschema on crates.io, the same way: once per version in their Cargo.toml files, the derive |
| 134 | + # first (envschema depends on it). Inert while either Cargo.toml says `publish = false`. Before that line goes, the |
| 135 | + # first release of each is published by hand with a per-crate token, and trusted publishing is configured on |
| 136 | + # crates.io for both crates (DocSpring/visualci, release.yml); this job then publishes every later version. |
| 137 | + envschema: |
| 138 | + if: github.event_name == 'push' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push') |
| 139 | + runs-on: ubuntu-latest |
| 140 | + permissions: |
| 141 | + contents: read |
| 142 | + id-token: write |
| 143 | + steps: |
| 144 | + - uses: actions/checkout@v4 |
| 145 | + with: |
| 146 | + ref: ${{ github.event.workflow_run.head_sha || github.sha }} |
| 147 | + - id: version |
| 148 | + run: | |
| 149 | + publish= |
| 150 | + for crate in envschema-derive envschema; do |
| 151 | + manifest=crates/$crate/Cargo.toml |
| 152 | + if grep -q '^publish = false' "$manifest"; then |
| 153 | + echo "$crate isn't published yet ($manifest says publish = false)" |
| 154 | + continue |
| 155 | + fi |
| 156 | + version=$(sed -n 's/^version = "\(.*\)"/\1/p' "$manifest" | head -1) |
| 157 | + code=$(curl -s -o /dev/null -w '%{http_code}' -A 'envschema release (github.com/DocSpring/visualci)' \ |
| 158 | + "https://crates.io/api/v1/crates/$crate/$version") |
| 159 | + if [ "$code" = 200 ]; then |
| 160 | + echo "$crate $version is already on crates.io" |
| 161 | + else |
| 162 | + publish="$publish $crate" |
| 163 | + fi |
| 164 | + done |
| 165 | + echo "crates=${publish# }" >> "$GITHUB_OUTPUT" |
| 166 | + - id: auth |
| 167 | + if: steps.version.outputs.crates != '' |
| 168 | + uses: rust-lang/crates-io-auth-action@v1 |
| 169 | + - if: steps.version.outputs.crates != '' |
| 170 | + env: |
| 171 | + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |
| 172 | + CRATES: ${{ steps.version.outputs.crates }} |
| 173 | + run: | |
| 174 | + for crate in $CRATES; do |
| 175 | + cargo publish --locked -p "$crate" |
| 176 | + done |
0 commit comments