forked from itsbalamurali/gpui-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (71 loc) · 2.63 KB
/
Copy pathpublish.yml
File metadata and controls
81 lines (71 loc) · 2.63 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
76
77
78
79
80
81
name: Publish to crates.io
on:
release:
types: [published]
workflow_dispatch:
inputs:
dry-run:
description: "Dry run (don't actually publish)"
required: false
default: "false"
type: boolean
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
publish:
name: Publish crate
runs-on: macos-14
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo registry + git deps
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: publish-cargo-${{ hashFiles('Cargo.lock', 'Cargo.toml') }}
restore-keys: publish-cargo-
- name: Verify crate version matches release tag
if: github.event_name == 'release'
run: |
CRATE_VERSION="v$(cargo metadata --no-deps --format-version 1 \
| jq -r '.packages[] | select(.name == "gpui-mobile") | .version')"
TAG="${{ github.event.release.tag_name }}"
echo "Crate version: $CRATE_VERSION"
echo "Release tag: $TAG"
if [ "$CRATE_VERSION" != "$TAG" ]; then
echo "::error::Crate version ($CRATE_VERSION) does not match release tag ($TAG)"
exit 1
fi
- name: Run tests before publishing
run: cargo test --lib
- name: Dry-run publish
if: github.event_name == 'workflow_dispatch' && inputs.dry-run == 'true'
run: cargo publish --dry-run
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish to crates.io
if: >-
(github.event_name == 'release') ||
(github.event_name == 'workflow_dispatch' && inputs.dry-run != 'true')
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Summary
if: success()
run: |
VERSION=$(cargo metadata --no-deps --format-version 1 \
| jq -r '.packages[] | select(.name == "gpui-mobile") | .version')
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.dry-run }}" = "true" ]; then
echo "### 🧪 Dry-run publish succeeded" >> "$GITHUB_STEP_SUMMARY"
echo "Version **$VERSION** is ready to publish." >> "$GITHUB_STEP_SUMMARY"
else
echo "### 📦 Published gpui-mobile v$VERSION" >> "$GITHUB_STEP_SUMMARY"
echo "View on [crates.io](https://crates.io/crates/gpui-mobile)" >> "$GITHUB_STEP_SUMMARY"
fi