Skip to content

Commit afe73b4

Browse files
committed
Add github workflows to release and test aiscript
1 parent 06e8d36 commit afe73b4

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed

.github/workflows/cargo-test.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Cargo Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Setup Rust
20+
uses: actions-rs/toolchain@v1
21+
with:
22+
profile: minimal
23+
toolchain: stable
24+
override: true
25+
components: rustfmt, clippy
26+
27+
- name: Cargo fmt
28+
uses: actions-rs/cargo@v1
29+
with:
30+
command: fmt
31+
args: --all -- --check
32+
33+
- name: Cargo clippy
34+
uses: actions-rs/cargo@v1
35+
with:
36+
command: clippy
37+
args: -- -D warnings
38+
39+
- name: Cargo test
40+
uses: actions-rs/cargo@v1
41+
with:
42+
command: xtest
43+
args: --verbose

.github/workflows/release.yaml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Release AIScript
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build:
10+
name: Build AIScript (${{ matrix.os }})
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
include:
15+
- os: ubuntu-latest
16+
target: x86_64-unknown-linux-gnu
17+
artifact_name: aiscript
18+
asset_name: aiscript-linux-x86_64
19+
- os: macos-latest
20+
target: x86_64-apple-darwin
21+
artifact_name: aiscript
22+
asset_name: aiscript-macos-x86_64
23+
- os: macos-latest
24+
target: aarch64-apple-darwin
25+
artifact_name: aiscript
26+
asset_name: aiscript-macos-arm64
27+
- os: windows-latest
28+
target: x86_64-pc-windows-msvc
29+
artifact_name: aiscript.exe
30+
asset_name: aiscript-windows-x86_64.exe
31+
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v3
35+
36+
- name: Setup Rust toolchain
37+
uses: actions-rs/toolchain@v1
38+
with:
39+
toolchain: stable
40+
target: ${{ matrix.target }}
41+
override: true
42+
43+
- name: Build binary
44+
uses: actions-rs/cargo@v1
45+
with:
46+
command: build
47+
args: --release --target ${{ matrix.target }}
48+
49+
- name: Move binary to final location
50+
shell: bash
51+
run: |
52+
mkdir -p dist
53+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
54+
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} dist/${{ matrix.asset_name }}
55+
else
56+
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} dist/${{ matrix.asset_name }}
57+
chmod +x dist/${{ matrix.asset_name }}
58+
fi
59+
60+
- name: Upload artifact
61+
uses: actions/upload-artifact@v3
62+
with:
63+
name: ${{ matrix.asset_name }}
64+
path: dist/${{ matrix.asset_name }}
65+
if-no-files-found: error
66+
67+
release:
68+
needs: build
69+
name: Create GitHub Release
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: Checkout code
73+
uses: actions/checkout@v3
74+
75+
- name: Download artifacts
76+
uses: actions/download-artifact@v3
77+
with:
78+
path: dist
79+
80+
# Add the install.sh script to the release
81+
- name: Prepare install script
82+
run: |
83+
cp install.sh dist/
84+
chmod +x dist/install.sh
85+
86+
# Generate checksums for all artifacts
87+
- name: Generate checksums
88+
run: |
89+
cd dist
90+
find . -type f -not -path "*/\.*" | grep -v "checksums.txt" | xargs -I{} shasum -a 256 {} > checksums.txt
91+
cat checksums.txt
92+
93+
- name: Create release
94+
id: create_release
95+
uses: softprops/action-gh-release@v1
96+
with:
97+
files: |
98+
dist/aiscript-linux-x86_64/aiscript-linux-x86_64
99+
dist/aiscript-macos-x86_64/aiscript-macos-x86_64
100+
dist/aiscript-macos-arm64/aiscript-macos-arm64
101+
dist/aiscript-windows-x86_64.exe/aiscript-windows-x86_64.exe
102+
dist/install.sh
103+
dist/checksums.txt
104+
draft: false
105+
prerelease: false
106+
generate_release_notes: true
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)