99 default : pinocchio
1010 type : choice
1111 options :
12- - pinocchio
13- - pubkey
12+ - programs/associated-token-account
13+ - programs/system
14+ - programs/token
15+ - sdk/log/crate
16+ - sdk/log/macro
17+ - sdk/pinocchio
18+ - sdk/pubkey
19+ level :
20+ description : Level
21+ required : true
22+ default : patch
23+ type : choice
24+ options :
25+ - patch
26+ - minor
27+ - major
28+ - version
29+ version :
30+ description : Version
31+ required : false
32+ type : string
1433 dry_run :
1534 description : Dry run
1635 required : true
1736 default : true
1837 type : boolean
38+ create_release :
39+ description : Create a GitHub release
40+ required : true
41+ type : boolean
42+ default : true
1943
2044env :
21- RUST_VERSION : 1.78.0
22- SOLANA_VERSION : 1.18.20
23- CARGO_CACHE : |
24- ~/.cargo/bin/
25- ~/.cargo/registry/index/
26- ~/.cargo/registry/cache/
27- ~/.cargo/git/db/
28- target/
45+ CACHE : true
2946
3047jobs :
3148 publish_release :
@@ -35,24 +52,71 @@ jobs:
3552 - name : Git checkout
3653 uses : actions/checkout@v4
3754
38- - name : Install Rust
39- uses : dtolnay/rust-toolchain@master
55+ - name : Setup Environment
56+ uses : ./.github/actions/setup
4057 with :
41- toolchain : stable
58+ cargo-cache-key : cargo-publish
59+ toolchain : test
4260
43- - name : Check semver
44- uses : obi1kenobi/cargo-semver-checks-action@v2
61+ - name : Install cargo-bump
62+ run : which cargo-bump || cargo install cargo-bump
63+
64+ - name : Install cargo-semver-checks
65+ run : which cargo-semver-checks || cargo install cargo-semver-checks
66+
67+ - name : Test
68+ run : pnpm test ${{ inputs.crate }}
69+
70+ - name : Ensure CARGO_REGISTRY_TOKEN variable is set
71+ env :
72+ token : ${{ secrets.CARGO_REGISTRY_TOKEN }}
73+ if : ${{ env.token == '' }}
74+ run : |
75+ echo "The CARGO_REGISTRY_TOKEN secret variable is not set"
76+ echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
77+ exit 1
78+
79+ - name : Set Git Author
80+ run : |
81+ git config --global user.email "[email protected] " 82+ git config --global user.name "github-actions"
4583
46- - name : Publish crate
84+ - name : Bump Version
85+ run : |
86+ if [ "${{ inputs.level }}" == "version" ]; then
87+ LEVEL=${{ inputs.version }}
88+ else
89+ LEVEL=${{ inputs.level }}
90+ fi
91+
92+ cargo bump $LEVEL
93+ echo BUMP="${LEVEL}" >> $GITHUB_ENV
94+
95+ - name : Check semver
96+ run : pnpm semver ${{ inputs.crate }}
97+
98+ - name : Publish Crate
99+ id : publish
47100 env :
48101 CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
49102 run : |
50- MANIFEST="./sdk/${{ inputs.crate }}/Cargo.toml"
103+ # Restore the workspace to the original state
104+ git restore .
51105
52106 if [ "${{ inputs.dry_run }}" == "true" ]; then
53107 OPTIONS="--dry-run"
54108 else
55109 OPTIONS=""
56110 fi
57111
58- cargo publish --manifest-path $MANIFEST $OPTIONS
112+ pnpm tsx ./scripts/publish.mts ${{ inputs.crate }} ${{ env.BUMP }} $OPTIONS
113+
114+ - name : Push Commit and Tag
115+ if : github.event.inputs.dry_run != 'true'
116+ run : git push origin --follow-tags
117+
118+ - name : Create GitHub release
119+ if : github.event.inputs.create_release == 'true' && github.event.inputs.dry_run != 'true'
120+ uses : ncipollo/release-action@v1
121+ with :
122+ tag : ${{ steps.publish.outputs.crate }}@v${{ steps.publish.outputs.version }}
0 commit comments