-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (89 loc) · 2.69 KB
/
rust.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Rust Build, Test, and Publish
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-gnu
archive: zip
- target: x86_64-unknown-linux-musl
archive: tar.gz tar.xz tar.zst
- target: x86_64-apple-darwin
archive: zip
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Install Rust toolchain
run: rustup target add ${{ matrix.target }}
- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Install dependencies for Windows target
if: matrix.target == 'x86_64-pc-windows-gnu'
run: sudo apt-get install mingw-w64 -y
- name: Build the project
run: cargo build --release --target ${{ matrix.target }}
- name: Run tests
run: cargo test --release --target ${{ matrix.target }}
- name: Package the build
run: |
mkdir -p dist
if [ "${{ matrix.archive }}" == "zip" ]; then
zip -j dist/ml2pdf-${{ matrix.target }}.zip target/${{ matrix.target }}/release/ml2pdf*
else
tar -czvf dist/ml2pdf-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release ml2pdf*
fi
with:
working-directory: .
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: rust-app-${{ matrix.target }}
path: dist/
publish:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: rust-app-${{ matrix.target }}
path: dist/
- name: Get current date
id: get_date
run: echo "DATE=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- name: Publish release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.DATE }}
release_name: Release ${{ env.DATE }}
draft: false
prerelease: false
- name: Upload artifacts to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/ml2pdf-${{ matrix.target }}.*
asset_name: ml2pdf-${{ matrix.target }}.${{ matrix.archive }}
asset_content_type: application/octet-stream
- name: Clean up artifacts
run: rm -rf dist/