Skip to content

Commit 26d91c8

Browse files
committed
Add ci and cd
1 parent 4b26e06 commit 26d91c8

File tree

3 files changed

+110
-14
lines changed

3 files changed

+110
-14
lines changed

.github/workflows/cd.yaml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Release & Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "**"
7+
8+
jobs:
9+
release:
10+
name: Create release
11+
runs-on: ubuntu-latest
12+
outputs:
13+
tag: ${{ steps.release-tag.outputs.tag }}
14+
id: ${{ steps.release-id.outputs.id }}
15+
steps:
16+
- name: Determine tag
17+
id: release-tag
18+
run: |
19+
RELEASE_TAG=${GITHUB_REF#refs/tags/}
20+
echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV
21+
echo "tag=${RELEASE_TAG}" >> $GITHUB_OUTPUT
22+
- name: Create the release
23+
run: |
24+
curl \
25+
-X POST \
26+
-H "Accept: application/vnd.github+json" \
27+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
28+
https://api.github.com/repos/${{ github.repository }}/releases \
29+
--data '{
30+
"tag_name": "${{ env.RELEASE_TAG }}",
31+
"name": "Release ${{ env.RELEASE_TAG }}",
32+
"generate_release_notes": true
33+
}' \
34+
-o release.json
35+
- name: Determine release id
36+
id: release-id
37+
run: |
38+
RELEASE_ID=$(jq -r '.id' release.json)
39+
echo "id=${RELEASE_ID}" >> $GITHUB_OUTPUT
40+
41+
build-and-publish:
42+
name: Build and publish
43+
runs-on: ${{ matrix.job.os }}
44+
strategy:
45+
matrix:
46+
job:
47+
- os: ubuntu-latest
48+
target: x86_64-unknown-linux-gnu
49+
- os: macos-latest
50+
target: x86_64-apple-darwin
51+
- os: windows-latest
52+
target: x86_64-pc-windows-msvc
53+
needs: release
54+
steps:
55+
- name: Checkout code
56+
uses: actions/checkout@v3
57+
- name: Build binary
58+
run: |
59+
rustup update stable
60+
rustup default stable
61+
rustup target add ${{ matrix.job.target }}
62+
cargo build --release --target ${{ matrix.job.target }}
63+
- name: Create tarball
64+
shell: bash
65+
run: |
66+
TARBALL=sws-${{ needs.release.outputs.tag }}-${{ matrix.job.target }}.tar.gz
67+
tar -zcvf ${TARBALL} -C target/${{ matrix.job.target }}/release sws
68+
echo "TARBALL=${TARBALL}" >> $GITHUB_ENV
69+
- name: Upload tarball to the release
70+
run: |
71+
curl \
72+
-X POST \
73+
-H "Accept: application/vnd.github+json" \
74+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
75+
-H 'Content-Type: application/octet-stream' \
76+
--upload-file ${{ env.TARBALL }} \
77+
https://uploads.github.com/repos/${{ github.repository }}/releases/${{ needs.release.outputs.id }}/assets?name=${{ env.TARBALL }}

.github/workflows/ci.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Build & Test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build-and-test:
14+
name: Build and test
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
steps:
20+
- uses: actions/checkout@v3
21+
- run: rustup update
22+
- run: cargo build
23+
- run: cargo fmt --check --all
24+
- run: cargo clippy -- -D warnings
25+
- run: cargo test --verbose

crates/sws-tree/src/lib.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,10 @@ impl<T> NodeRef<T> {
308308
.map(|child| child.id)
309309
.unwrap_or_else(NodeId::null);
310310

311-
tree.sm
312-
.borrow_mut()
313-
.get_mut(new_child_id)
314-
.map(|new_child| {
315-
new_child.parent = self.id;
316-
new_child.prev_sibling = last_child_id;
317-
});
311+
tree.sm.borrow_mut().get_mut(new_child_id).map(|new_child| {
312+
new_child.parent = self.id;
313+
new_child.prev_sibling = last_child_id;
314+
});
318315

319316
tree.sm
320317
.borrow_mut()
@@ -346,13 +343,10 @@ impl<T> NodeRef<T> {
346343
.map(|child| child.id)
347344
.unwrap_or_else(NodeId::null);
348345

349-
tree.sm
350-
.borrow_mut()
351-
.get_mut(new_child_id)
352-
.map(|new_child| {
353-
new_child.parent = self.id;
354-
new_child.next_sibling = first_child_id;
355-
});
346+
tree.sm.borrow_mut().get_mut(new_child_id).map(|new_child| {
347+
new_child.parent = self.id;
348+
new_child.next_sibling = first_child_id;
349+
});
356350

357351
tree.sm
358352
.borrow_mut()

0 commit comments

Comments
 (0)