-
Notifications
You must be signed in to change notification settings - Fork 39
111 lines (91 loc) · 3.27 KB
/
release.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
name: Release
on:
push:
branches:
- main
- release/*
- prerelease/*
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
version_or_publish:
name: Version packages or publish them to npmjs.com
runs-on: ubuntu-latest
outputs:
published: ${{ steps.changeset.outputs.published }}
version: ${{ steps.get_version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.BOT_TOKEN }}
- name: Register Git user
run: |
git config user.name rollups-contracts-bot
git config user.email [email protected]
- uses: ./.github/workflows/setup
- name: Create release PR or publish packages to npmjs.com
uses: changesets/action@f13b1baaa620fde937751f5d2c3572b9da32af23
id: changeset
with:
setupGitUser: false
commit: "chore: version packages"
publish: pnpm changeset publish
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Get version
id: get_version
run: jq -r '"version=\(.version)"' package.json >> "$GITHUB_OUTPUT"
upload_contract_artifacts_to_gh_releases:
name: Upload contract artifacts to GitHub Releases
needs: version_or_publish
if: ${{ needs.version_or_publish.outputs.published == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: ./.github/workflows/setup
- name: Build contracts
run: pnpm build
- name: Create upload folder
run: mkdir -p upload
- name: Compress contract artifacts
run: tar -czf "$FILEPATH" -C export/artifacts/contracts .
env:
FILEPATH: upload/rollups-contracts-${{ needs.version_or_publish.outputs.version }}-artifacts.tar.gz
- name: Upload files to GitHub Releases
uses: softprops/action-gh-release@v2
with:
files: upload/*
rust_bindings:
name: Generate and publish Rust bindings
needs: version_or_publish
if: ${{ needs.version_or_publish.outputs.published == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: ./.github/workflows/setup
- name: Install Python dependencies
run: pip install yq
- name: Generate Rust bindings
run: |
forge bind \
--crate-name cartesi-rollups-contracts \
--crate-version "$VERSION" \
--alloy
env:
VERSION: ${{ needs.version_or_publish.outputs.version }}
- name: Edit Rust package manifest
working-directory: out/bindings
run: |
tomlq -ti '.package.license = "Apache-2.0"' Cargo.toml
tomlq -ti '.package.description = "Rust bindings for Cartesi Rollups smart contracts"' Cargo.toml
tomlq -ti 'del(.dependencies.alloy.git)' Cargo.toml
tomlq -ti '.dependencies.alloy.version = "0.3.1"' Cargo.toml
- name: Publish Rust package to crates.io
working-directory: out/bindings
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}