@@ -2,10 +2,10 @@ name: CI
2
2
3
3
on :
4
4
push :
5
- branches : [ main ]
6
- tags : [ 'v*' ]
5
+ branches : [main]
6
+ tags : ["v*" ]
7
7
pull_request :
8
- branches : [ main ]
8
+ branches : [main]
9
9
10
10
env :
11
11
CARGO_TERM_COLOR : always
@@ -16,13 +16,27 @@ permissions:
16
16
jobs :
17
17
test :
18
18
name : Test
19
- runs-on : ubuntu-latest
19
+ runs-on : ${{ matrix.os }}
20
+ strategy :
21
+ matrix :
22
+ os : [ubuntu-latest, windows-latest]
20
23
steps :
21
24
- uses : actions/checkout@v3
22
- - uses : dtolnay/rust-toolchain@stable
25
+
26
+ - name : Install Rust
27
+ uses : dtolnay/rust-toolchain@stable
28
+
23
29
- uses : Swatinem/rust-cache@v2
30
+
31
+ - name : Install Node (Windows)
32
+ if : startsWith(matrix.os, 'windows-')
33
+ run : choco install nodejs-lts --no-progress
34
+
35
+ - name : Show Node version
36
+ run : node --version || echo "No Node"
37
+
24
38
- name : Run tests
25
- run : cargo test
39
+ run : cargo test --verbose
26
40
27
41
lint :
28
42
name : Lint
56
70
target : aarch64-apple-darwin
57
71
artifact_name : yek
58
72
asset_name : yek-aarch64-apple-darwin.tar.gz
73
+ - os : windows-latest
74
+ target : x86_64-pc-windows-msvc
75
+ artifact_name : yek.exe
76
+ asset_name : yek-x86_64-pc-windows-msvc.zip
77
+ - os : windows-latest
78
+ target : aarch64-pc-windows-msvc
79
+ artifact_name : yek.exe
80
+ asset_name : yek-aarch64-pc-windows-msvc.zip
59
81
steps :
60
82
- uses : actions/checkout@v3
61
83
- uses : dtolnay/rust-toolchain@stable
@@ -70,29 +92,67 @@ jobs:
70
92
staging="yek-${{ matrix.target }}"
71
93
mkdir -p "$staging"
72
94
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "$staging/"
73
- tar czf "${{ matrix.asset_name }}" "$staging"
95
+ if [[ "${{ matrix.asset_name }}" == *.zip ]]; then
96
+ 7z a "${{ matrix.asset_name }}" "$staging"
97
+ else
98
+ tar czf "${{ matrix.asset_name }}" "$staging"
99
+ fi
74
100
- name : Upload artifact
75
101
uses : actions/upload-artifact@v3
76
102
with :
77
103
name : ${{ matrix.asset_name }}
78
104
path : ${{ matrix.asset_name }}
79
-
105
+
80
106
release :
81
107
name : Release
82
108
needs : [test, lint, build]
83
109
runs-on : ubuntu-latest
84
- if : startsWith(github.ref, 'refs/tags/')
85
110
steps :
111
+ - uses : actions/checkout@v3
112
+ with :
113
+ fetch-depth : 0
114
+ - name : Semantic Release
115
+ uses : cycjimmy/semantic-release-action@v4
116
+ id : semantic
117
+ env :
118
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
86
119
- uses : actions/download-artifact@v3
120
+ if : steps.semantic.outputs.new_release_published == 'true'
87
121
with :
88
122
path : artifacts
89
- - name : List artifacts
90
- run : ls -R artifacts
91
123
- name : Move artifacts
124
+ if : steps.semantic.outputs.new_release_published == 'true'
92
125
run : |
93
126
mv artifacts/*/*.tar.gz ./
94
- - name : Create Release
127
+ mv artifacts/*/*.zip ./
128
+ - name : Update Release with Artifacts
129
+ if : steps.semantic.outputs.new_release_published == 'true'
95
130
uses : softprops/action-gh-release@v1
96
131
with :
132
+ tag_name : v${{ steps.semantic.outputs.new_release_version }}
97
133
files : |
98
- *.tar.gz
134
+ *.tar.gz
135
+ *.zip
136
+ - name : Copy installation script to bodo.run
137
+ if : steps.semantic.outputs.new_release_published == 'true'
138
+ run : |
139
+ git config --global user.name 'github-actions[bot]'
140
+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
141
+ git clone https://${{ secrets.PAT_TOKEN }}@github.com/bodo-run/bodo-run.github.io.git
142
+ cp scripts/install_yek.sh bodo-run.github.io/public/yek.sh
143
+ cp scripts/install_yek.ps1 bodo-run.github.io/public/yek.ps1
144
+ COMMIT_SHA=$(git rev-parse HEAD)
145
+ BODO_COMMIT_MESSAGE=$(git log -1 --pretty=%B)
146
+ cd bodo-run.github.io
147
+ git add public/yek.sh public/yek.ps1
148
+ # Exit with 0 if no changes
149
+ if git diff --exit-code; then
150
+ echo "No changes to commit"
151
+ exit 0
152
+ fi
153
+ git commit -m "Update yek installation scripts" \
154
+ -m "" \
155
+ -m "$BODO_COMMIT_MESSAGE" \
156
+ -m "" \
157
+ -m "https://github.com/bodo-run/yek/commit/$COMMIT_SHA"
158
+ git push
0 commit comments