Skip to content

Commit ffd0f23

Browse files
committed
actions: Update deploy
1 parent edb4200 commit ffd0f23

File tree

1 file changed

+94
-87
lines changed

1 file changed

+94
-87
lines changed

.github/workflows/deploy.yml

Lines changed: 94 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -7,126 +7,133 @@ on:
77

88
jobs:
99

10-
windows-binaries:
10+
create-windows-binaries:
1111

1212
runs-on: windows-latest
1313

1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1616

1717
- name: Install stable
18-
uses: actions-rs/toolchain@v1
19-
with:
20-
profile: minimal
21-
toolchain: stable
22-
override: true
18+
uses: dtolnay/rust-toolchain@stable
2319

24-
- name: Build json-diff
20+
- name: Build jsons-structural-diff
2521
run: |
2622
cargo build --release --workspace
2723
28-
- name: Create zip
24+
- name: Get the version
25+
shell: bash
26+
id: tagName
2927
run: |
30-
cd target/release
31-
7z a ../../json-structural-diff-windows-msvc.zip `
32-
"json-structural-diff-cli.exe"
28+
VERSION=$(cargo pkgid | cut -d# -f2)
29+
echo "tag=$VERSION" >> $GITHUB_OUTPUT
3330
34-
- name: Upload binaries
35-
uses: actions/upload-artifact@v2
31+
- name: Build package
32+
id: package
33+
shell: bash
34+
run: |
35+
ARCHIVE_TARGET="x86_64-pc-windows-msvc"
36+
ARCHIVE_NAME="json-structural-diff-${{ steps.tagName.outputs.tag }}-$ARCHIVE_TARGET"
37+
ARCHIVE_FILE="${ARCHIVE_NAME}.zip"
38+
7z a ${ARCHIVE_FILE} ./target/release/json-structural-diff-cli.exe
39+
echo "file=$ARCHIVE_FILE" >> $GITHUB_OUTPUT
40+
echo "name=$ARCHIVE_NAME.zip" >> $GITHUB_OUTPUT
41+
42+
- name: Upload artifacts
43+
uses: actions/upload-artifact@v3
3644
with:
37-
name: json-diff-windows-msvc-binaries
38-
path: json-structural-diff-windows-msvc.zip
45+
name: ${{ steps.package.outputs.name }}
46+
path: ${{ steps.package.outputs.file }}
3947

40-
linux-binaries:
48+
create-unix-binaries:
4149

42-
runs-on: ubuntu-latest
50+
strategy:
51+
matrix:
52+
os: [ubuntu-latest, macos-latest]
53+
include:
54+
- os: ubuntu-latest
55+
target: x86_64-unknown-linux-musl
56+
- os: macos-latest
57+
target: x86_64-apple-darwin
4358

44-
steps:
45-
- uses: actions/checkout@v2
59+
runs-on: ${{ matrix.os }}
4660

47-
- name: Install musl-tools
48-
run: |
49-
sudo apt-get install musl-tools
61+
steps:
62+
- uses: actions/checkout@v4
5063

51-
- name: Install Rust stable and musl target
52-
uses: actions-rs/toolchain@v1
64+
- name: Install Rust stable
65+
uses: dtolnay/rust-toolchain@stable
5366
with:
54-
profile: minimal
55-
toolchain: stable
56-
target: x86_64-unknown-linux-musl
57-
override: true
67+
target: ${{ matrix.target }}
5868

59-
- name: Build json-diff
69+
- name: Install musl
70+
if: contains(matrix.target, 'linux-musl')
6071
run: |
61-
cargo build --workspace --release --target x86_64-unknown-linux-musl
72+
sudo apt-get install musl-tools
6273
63-
- name: Create zip
74+
- name: Build json-structural-diff
6475
run: |
65-
cd target/x86_64-unknown-linux-musl/release
66-
strip json-structural-diff-cli
67-
tar -czvf $GITHUB_WORKSPACE/json-structural-diff-linux.tar.gz \
68-
json-structural-diff-cli
69-
70-
- name: Upload binaries
71-
uses: actions/upload-artifact@v2
72-
with:
73-
name: json-diff-linux-binaries
74-
path: json-structural-diff-linux.tar.gz
75-
76-
macos-binaries:
77-
78-
runs-on: macos-latest
76+
cargo build --workspace --release --target ${{ matrix.target }}
7977
80-
steps:
81-
- uses: actions/checkout@v2
82-
83-
- name: Install stable
84-
uses: actions-rs/toolchain@v1
85-
with:
86-
profile: minimal
87-
toolchain: stable
88-
override: true
89-
90-
- name: Build json-diff
78+
- name: Strip binary
9179
run: |
92-
cargo build --workspace --release
80+
strip target/${{ matrix.target }}/release/json-structural-diff-cli
9381
94-
- name: Create zip
82+
- name: Get the version
83+
id: tagName
9584
run: |
96-
cd target/release
97-
strip json-structural-diff-cli
98-
zip $GITHUB_WORKSPACE/json-structural-diff-macos.zip \
99-
json-structural-diff-cli
85+
VERSION=$(cargo pkgid | cut -d# -f2)
86+
echo "tag=$VERSION" >> $GITHUB_OUTPUT
10087
101-
- name: Upload binaries
102-
uses: actions/upload-artifact@v2
88+
- name: Build package
89+
id: package
90+
run: |
91+
TAR_FILE=json-structural-diff-${{ steps.tagName.outputs.tag }}-${{ matrix.target }}
92+
cd target/${{ matrix.target }}/release
93+
tar -czvf $GITHUB_WORKSPACE/$TAR_FILE.tar.gz json-structural-diff-cli
94+
echo "name=$TAR_FILE" >> $GITHUB_OUTPUT
95+
echo "file=$TAR_FILE.tar.gz" >> $GITHUB_OUTPUT
96+
97+
- name: Upload artifacts
98+
uses: actions/upload-artifact@v3
10399
with:
104-
name: json-diff-macos-binaries
105-
path: json-structural-diff-macos.zip
100+
name: ${{ steps.package.outputs.name }}
101+
path: ${{ steps.package.outputs.file }}
102+
106103

107104
deploy:
108105

109-
needs: [windows-binaries, linux-binaries, macos-binaries]
106+
needs: [create-windows-binaries, create-unix-binaries]
110107

111108
runs-on: ubuntu-latest
112109

113110
steps:
114-
- uses: actions/checkout@v2
115-
116-
- name: Download zip files
117-
uses: actions/download-artifact@v2
118-
119-
- name: Create Cargo.lock
120-
run: |
121-
cargo update
122-
123-
- name: Create a release
124-
uses: softprops/action-gh-release@v1
125-
with:
126-
files: |
127-
Cargo.lock
128-
json-diff-linux-binaries/json-structural-diff-linux.tar.gz
129-
json-diff-macos-binaries/json-structural-diff-macos.zip
130-
json-diff-windows-msvc-binaries/json-structural-diff-windows-msvc.zip
131-
env:
132-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
- uses: actions/checkout@v4
112+
113+
- name: Install Rust stable
114+
uses: dtolnay/rust-toolchain@stable
115+
116+
- name: Create Cargo.lock
117+
run: |
118+
cargo update
119+
120+
- name: Get version
121+
id: tagName
122+
run: |
123+
VERSION=$(cargo pkgid | cut -d# -f2)
124+
echo "tag=$VERSION" >> $GITHUB_OUTPUT
125+
126+
- name: Download artifacts
127+
uses: actions/download-artifact@v2
128+
with:
129+
path: ./binaries
130+
131+
- name: Create a release
132+
uses: softprops/action-gh-release@v1
133+
with:
134+
name: v${{ steps.tagName.outputs.tag }}
135+
files: |
136+
./binaries/**/*.zip
137+
./binaries/**/*.tar.gz
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)