-
Notifications
You must be signed in to change notification settings - Fork 69
149 lines (131 loc) · 4.24 KB
/
publish-rust.yml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Publish Rust Crate
on:
workflow_dispatch:
inputs:
package_path:
description: Path to directory with package to release
required: true
type: string
level:
description: Level
required: true
default: patch
type: choice
options:
- patch
- minor
- major
- rc
- beta
- alpha
- release
- version
version:
description: Version (used with level "version")
required: false
type: string
dry_run:
description: Dry run
required: true
default: true
type: boolean
create_release:
description: Create a GitHub release
required: true
type: boolean
default: true
jobs:
test:
name: Test Rust Crate
runs-on: ubuntu-latest
if: false
steps:
- name: Git Checkout
uses: actions/checkout@v4
- name: Setup Environment
uses: ./.github/actions/setup
with:
clippy: true
rustfmt: true
solana: true
cli: true
purge: true
cargo-cache-key: cargo-test-publish-${{ inputs.package_path }}
cargo-cache-fallback-key: cargo-test-publish
- name: Format
run: pnpm zx ./scripts/rust/format.mjs "${{ inputs.package_path }}"
- name: Lint
run: pnpm zx ./scripts/rust/lint.mjs "${{ inputs.package_path }}"
- name: Build Token-2022
run: pnpm programs:build
- name: Build ElGamal Registry
run: pnpm confidential-transfer:elgamal-registry:build
- name: Test
run: pnpm zx ./scripts/rust/test.mjs "${{ inputs.package_path }}"
publish:
name: Publish Rust Crate
runs-on: ubuntu-latest
#needs: test
permissions:
contents: write
steps:
- name: Git Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.ANZA_TEAM_PAT }}
fetch-depth: 0 # get the whole history for git-cliff
- name: Setup Environment
uses: ./.github/actions/setup
with:
cli: true
cargo-cache-key: cargo-publish-${{ inputs.package_path }}
cargo-cache-fallback-key: cargo-publish
- name: Install Cargo Release
run: which cargo-release || cargo install cargo-release
- name: Ensure CARGO_REGISTRY_TOKEN variable is set
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
if: ${{ env.CARGO_REGISTRY_TOKEN == '' }}
run: |
echo "The CARGO_REGISTRY_TOKEN secret variable is not set"
echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
exit 1
- name: Set Git Author
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Publish Crate
id: publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
if [ "${{ inputs.level }}" == "version" ]; then
LEVEL=${{ inputs.version }}
else
LEVEL=${{ inputs.level }}
fi
if [ "${{ inputs.dry_run }}" == "true" ]; then
OPTIONS="--dry-run"
else
OPTIONS=""
fi
pnpm rust:publish "${{ inputs.package_path }}" $LEVEL $OPTIONS
- name: Generate a changelog
if: github.event.inputs.create_release == 'true'
uses: orhun/git-cliff-action@v3
with:
config: "scripts/cliff.toml"
args: |
"${{ steps.publish.outputs.old_git_tag }}"..master
--include-path "${{ inputs.package_path }}/**"
--github-repo "${{ github.repository }}"
env:
OUTPUT: TEMP_CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: Create GitHub release
if: github.event.inputs.create_release == 'true' && github.event.inputs.dry_run != 'true'
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.publish.outputs.new_git_tag }}
bodyFile: TEMP_CHANGELOG.md
name: ${{ steps.publish.outputs.release_title }}