Repository navigation
75 lines (64 loc) · 2.69 KB
/
Copy pathinitial-publish.yaml
File metadata and controls
75 lines (64 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Initial crates.io publish
on:
workflow_dispatch:
inputs:
package:
description: Initial crate to publish (formatter first)
required: true
type: choice
options: [stack-formatter, stack-engine]
expected_sha:
description: Exact main commit whose CI has succeeded
required: true
type: string
permissions:
contents: read
actions: read
concurrency:
group: initial-crates-io-publish
cancel-in-progress: false
defaults:
run:
shell: bash
jobs:
publish:
runs-on: ubuntu-24.04
timeout-minutes: 15
env:
PACKAGE_NAME: ${{ inputs.package }}
EXPECTED_SHA: ${{ inputs.expected_sha }}
steps:
- name: Reject unexpected dispatch context
run: |
test "$GITHUB_REPOSITORY" = stack-sh/engine
test "$GITHUB_REF" = refs/heads/main
[[ "$EXPECTED_SHA" =~ ^[0-9a-f]{40}$ ]]
test "$GITHUB_SHA" = "$EXPECTED_SHA"
[[ "$PACKAGE_NAME" = stack-formatter || "$PACKAGE_NAME" = stack-engine ]]
- name: Check out the exact dispatch commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Install the minimum supported Rust toolchain
run: rustup toolchain install 1.85.0 --profile minimal
- name: Verify package identity and successful main CI
env:
GH_TOKEN: ${{ github.token }}
run: |
test "$(git rev-parse HEAD)" = "$EXPECTED_SHA"
cargo +1.85.0 metadata --no-deps --locked --format-version 1 > "$RUNNER_TEMP/package.json"
gh run list --repo stack-sh/engine --workflow ci.yaml --event push --branch main --commit "$EXPECTED_SHA" --limit 1 --json status,conclusion,headSha > "$RUNNER_TEMP/ci.json"
node scripts/initial-publish-context.mjs "$RUNNER_TEMP/package.json" "$RUNNER_TEMP/ci.json"
- name: Require an unpublished crate name
run: |
code=$(curl --silent --show-error --max-time 30 --user-agent 'stack-sh/engine initial publication (https://github.com/stack-sh/engine)' --output "$RUNNER_TEMP/crate-state.json" --write-out '%{http_code}' https://crates.io/api/v1/crates/"$PACKAGE_NAME")
test "$code" = 404
- name: Verify the exact source package without credentials
run: cargo +1.85.0 publish --package "$PACKAGE_NAME" --registry crates-io --locked --dry-run
- name: Publish the initial crate
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_INITIAL_PUBLISH_TOKEN }}
run: |
test -n "$CARGO_REGISTRY_TOKEN"
cargo +1.85.0 publish --package "$PACKAGE_NAME" --registry crates-io --locked