-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (98 loc) · 3.34 KB
/
publish.yml
File metadata and controls
104 lines (98 loc) · 3.34 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: publish
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
dry_run:
description: "Run cargo publish in dry-run mode"
required: true
default: true
type: boolean
packages:
description: "Comma-separated package list; empty publishes the full workspace"
required: false
default: ""
type: string
skip_published:
description: "Skip versions that already exist on crates.io during a real publish"
required: true
default: true
type: boolean
permissions:
contents: read
jobs:
release-preflight:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip2
- uses: Swatinem/rust-cache@v2
- name: validate tag matches workspace version
run: |
set -euo pipefail
tag_version="${GITHUB_REF_NAME#v}"
pkgid="$(cargo pkgid -p aelf-sdk)"
workspace_version="${pkgid##*@}"
if [[ "$workspace_version" == "$pkgid" ]]; then
workspace_version="${pkgid##*#}"
fi
if [[ "$tag_version" != "$workspace_version" ]]; then
echo "::error::Tag version ${tag_version} does not match workspace version ${workspace_version}."
exit 1
fi
- name: install cargo-audit
run: cargo install cargo-audit --locked
- name: fmt
run: cargo fmt --all -- --check
- name: msrv
run: cargo +1.85.0 check --workspace --all-targets --all-features --locked
- name: clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: audit
run: cargo audit
- name: examples
run: cargo check --workspace --examples
- name: wasm aelf-client
run: cargo check -p aelf-client --target wasm32-wasip2 --no-default-features
- name: wasm aelf-contract
run: cargo check -p aelf-contract --target wasm32-wasip2 --no-default-features
- name: wasm aelf-sdk
run: cargo check -p aelf-sdk --target wasm32-wasip2 --no-default-features
- name: test
run: cargo test --workspace
- name: public readonly smoke
run: cargo test -p aelf-sdk --test public_readonly_smoke -- --ignored --test-threads=1 --nocapture
tag-publish:
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs: release-preflight
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: publish crates
env:
DRY_RUN: "false"
SELECTED_PACKAGES: ""
SKIP_PUBLISHED: "true"
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: ./scripts/publish-crates.sh
manual-publish:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: publish crates
env:
DRY_RUN: ${{ inputs.dry_run }}
SELECTED_PACKAGES: ${{ inputs.packages }}
SKIP_PUBLISHED: ${{ inputs.skip_published }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: ./scripts/publish-crates.sh