-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (97 loc) · 3.61 KB
/
Copy pathrelease.yml
File metadata and controls
113 lines (97 loc) · 3.61 KB
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
106
107
108
109
110
111
112
113
name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
name: Build for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
target: [x86_64, aarch64]
exclude:
- os: ubuntu-latest
target: aarch64
include:
- os: ubuntu-latest
target: x86_64
rust_target: x86_64-unknown-linux-gnu
artifact_name: pdf-to-markdown-linux-x86_64
- os: macos-latest
target: x86_64
rust_target: x86_64-apple-darwin
artifact_name: pdf-to-markdown-macos-x86_64
- os: macos-latest
target: aarch64
rust_target: aarch64-apple-darwin
artifact_name: pdf-to-markdown-macos-aarch64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_target }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Run tests
run: cargo test --release
- name: Build release
run: cargo build --release --target ${{ matrix.rust_target }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: target/${{ matrix.rust_target }}/release/pdf-to-markdown${{ matrix.os == 'windows-latest' && '.exe' || '' }}
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Display structure of downloaded files
run: |
ls -la
echo "--- Linux artifact ---"
ls -la pdf-to-markdown-linux-x86_64/ || echo "Directory not found"
echo "--- macOS artifact ---"
ls -la pdf-to-markdown-macos-x86_64/ || echo "Directory not found"
- name: Rename artifacts with platform suffix
run: |
if [ -d "pdf-to-markdown-linux-x86_64" ]; then
mv pdf-to-markdown-linux-x86_64/pdf-to-markdown pdf-to-markdown-linux-x86_64/pdf-to-markdown-linux-x86_64
chmod +x pdf-to-markdown-linux-x86_64/pdf-to-markdown-linux-x86_64
ls -la pdf-to-markdown-linux-x86_64/
fi
if [ -d "pdf-to-markdown-macos-x86_64" ]; then
mv pdf-to-markdown-macos-x86_64/pdf-to-markdown pdf-to-markdown-macos-x86_64/pdf-to-markdown-macos-x86_64
chmod +x pdf-to-markdown-macos-x86_64/pdf-to-markdown-macos-x86_64
ls -la pdf-to-markdown-macos-x86_64/
fi
if [ -d "pdf-to-markdown-macos-aarch64" ]; then
mv pdf-to-markdown-macos-aarch64/pdf-to-markdown pdf-to-markdown-macos-aarch64/pdf-to-markdown-macos-aarch64
chmod +x pdf-to-markdown-macos-aarch64/pdf-to-markdown-macos-aarch64
ls -la pdf-to-markdown-macos-aarch64/
fi
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
pdf-to-markdown-linux-x86_64/pdf-to-markdown-linux-x86_64
pdf-to-markdown-macos-x86_64/pdf-to-markdown-macos-x86_64
pdf-to-markdown-macos-aarch64/pdf-to-markdown-macos-aarch64
generate_release_notes: true