@@ -17,10 +17,17 @@ jobs:
17
17
runs-on : ubuntu-latest
18
18
steps :
19
19
- uses : actions/checkout@v4
20
-
20
+ - uses : actions/cache@v3
21
+ with :
22
+ path : |
23
+ ~/.cargo/bin/
24
+ ~/.cargo/registry/index/
25
+ ~/.cargo/registry/cache/
26
+ ~/.cargo/git/db/
27
+ target/
28
+ key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
21
29
- name : Test
22
30
run : cargo test -F bin,wasm
23
-
24
31
- name : Lint
25
32
run : cargo clippy -F bin,wasm
26
33
@@ -35,63 +42,111 @@ jobs:
35
42
id : version
36
43
run : echo "version=${GITHUB_REF##refs/tags/v}" >> $GITHUB_OUTPUT
37
44
38
- build :
45
+ build-wasm :
39
46
runs-on : ubuntu-latest
40
47
needs : version
41
48
steps :
42
49
- uses : actions/checkout@v4
50
+ - uses : oven-sh/setup-bun@v1
51
+ - name : Install npm packages
52
+ run : bun install --frozen-lockfile
53
+ - name : Build wasm
54
+ run : |
55
+ bun run build
56
+ cd pkg/
57
+ cp ../.npmrc .
58
+ npm version --no-git-tag-version '${{ needs.version.outputs.version }}'
59
+ - uses : actions/upload-artifact@v3
60
+ with :
61
+ if-no-files-found : error
62
+ name : base-converter-wasm
63
+ path : pkg/
43
64
44
- - name : Override version
45
- run : sed -i 's/^version = ".+"$/version = "${{ needs.version.outputs.version }}"/' Cargo.toml
46
-
65
+ build :
66
+ needs : version
67
+ strategy :
68
+ max-parallel : 1
69
+ matrix :
70
+ os : [ubuntu-latest,
71
+ # macos-latest-xlarge
72
+ ]
73
+ runs-on : ${{ matrix.os }}
74
+ steps :
75
+ - uses : actions/checkout@v4
76
+ - uses : actions/cache@v3
77
+ with :
78
+ path : |
79
+ ~/.cargo/bin/
80
+ ~/.cargo/registry/index/
81
+ ~/.cargo/registry/cache/
82
+ ~/.cargo/git/db/
83
+ target/
84
+ key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
47
85
- name : Install cross
48
86
run : cargo install cross --git https://github.com/cross-rs/cross
49
-
87
+ - name : Override version
88
+ run : |
89
+ if "$(uname -s)" = "Darwin"; then
90
+ SED="sed -i ''"
91
+ else
92
+ SED="sed -i"
93
+ fi
94
+ $SED -E 's/^version = ".+"$/version = "${{ needs.version.outputs.version }}"/' Cargo.toml
50
95
- name : Build cross platforms
96
+ if : matrix.os == 'ubuntu-latest'
51
97
run : |
52
- cross build --release --locked --target aarch64-unknown-linux-gnu
53
- cross build --release --locked --target aarch64-unknown-linux-musl
54
- cross build --release --locked --target x86_64-unknown-linux-gnu
55
- cross build --release --locked --target x86_64-unknown-linux-musl
56
- cross build --release --locked --target x86_64-pc-windows-gnu
57
-
98
+ cross build --release --locked --bin base-converter -F bin --target aarch64-unknown-linux-gnu
99
+ cross build --release --locked --bin base-converter -F bin --target aarch64-unknown-linux-musl
100
+ cross build --release --locked --bin base-converter -F bin --target x86_64-unknown-linux-gnu
101
+ cross build --release --locked --bin base-converter -F bin --target x86_64-unknown-linux-musl
102
+ cross build --release --locked --bin base-converter -F bin --target x86_64-pc-windows-gnu
58
103
mkdir tmp/
59
104
mv ./target/aarch64-unknown-linux-gnu/release/base-converter ./tmp/base-converter-aarch64-unknown-linux-gnu
60
105
mv ./target/aarch64-unknown-linux-musl/release/base-converter ./tmp/base-converter-aarch64-unknown-linux-musl
61
106
mv ./target/x86_64-unknown-linux-gnu/release/base-converter ./tmp/base-converter-x86_64-unknown-linux-gnu
62
107
mv ./target/x86_64-unknown-linux-musl/release/base-converter ./tmp/base-converter-x86_64-unknown-linux-musl
63
- mv ./target/x86_64-pc-windows-gnu/release/base-converter ./tmp/base-converter-x86_64-pc-windows-gnu
64
-
65
- # - name: Install wasm-pack
66
- # run: curl -fL --tlsv1.2 --proto '=https' https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
67
-
68
- # - name: Build wasm
69
- # run: wasm-pack build --target web --scope ctison . -F wasm
70
-
71
- # - name: Publish on npmjs.com
72
- # working-directory: pkg/
73
- # env:
74
- # NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
75
- # run: npm publish
108
+ mv ./target/x86_64-pc-windows-gnu/release/base-converter.exe ./tmp/base-converter-x86_64-pc-windows-gnu.exe
109
+ - name : Build macos
110
+ if : matrix.os == 'macos-latest-xlarge'
111
+ run : |
112
+ cargo build --release --locked --bin base-converter -F bin
113
+ mkdir tmp/
114
+ mv ./target/aarch64-apple-darwin/release/base-converter ./tmp/base-converter-aarch64-apple-darwin
115
+ - uses : actions/upload-artifact@v3
116
+ with :
117
+ if-no-files-found : error
118
+ name : cli-${{ matrix.os }}
119
+ path : tmp/
76
120
121
+ release :
122
+ runs-on : ubuntu-latest
123
+ needs : [version, build-wasm, build]
124
+ steps :
125
+ - uses : actions/checkout@v4
126
+ - uses : actions/download-artifact@v3
127
+ with :
128
+ path : dist/
129
+ - name : Publish on npmjs.com
130
+ working-directory : dist/base-converter-wasm
131
+ env :
132
+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
133
+ run : npm publish
77
134
- name : Publish on crates.io
78
135
env :
79
136
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
80
- run : cargo publish --allow-dirty --locked
81
-
137
+ run : |
138
+ sed -i -E 's/^version = ".+"$/version = "${{ needs.version.outputs.version }}"/' Cargo.toml
139
+ cargo publish --allow-dirty --locked
82
140
- name : Github Release
83
141
uses : softprops/action-gh-release@v1
84
142
with :
85
143
generate_release_notes : true
86
144
fail_on_unmatched_files : true
145
+ tag_name : v${{ needs.version.outputs.version }}
87
146
files : |
88
- ./tmp/base-converter-aarch64-unknown-linux-gnu
89
- ./tmp/base-converter-aarch64-unknown-linux-musl
90
- ./tmp/base-converter-x86_64-unknown-linux-gnu
91
- ./tmp/base-converter-x86_64-unknown-linux-musl
92
- ./tmp/base-converter-x86_64-pc-windows-gnu
147
+ ./dist/cli-*/*
93
148
body : |
94
149
# Rust Doc
95
- https://docs.rs/base-converter/${{ steps .version.outputs.version }}/base_converter/
96
- # # # NPM Package
97
- # https://www.npmjs.com/package/base-converter/v/${{ steps .version.outputs.version }}
150
+ https://docs.rs/base-converter/${{ needs .version.outputs.version }}/base_converter/
151
+ # NPM Package
152
+ https://www.npmjs.com/package/@ctison/ base-converter/v/${{ needs .version.outputs.version }}
0 commit comments