-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (82 loc) · 3.58 KB
/
release-build.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
name: Release
on:
release:
types: [published]
jobs:
release:
name: Release - ${{ matrix.platform.release_for }}
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
platform:
- release_for: Linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- release_for: macOS-Intel
os: macos-12
target: x86_64-apple-darwin
- release_for: macOS-ARM
os: macos-latest
target: aarch64-apple-darwin
- release_for: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.platform.target }}
override: true
- name: Build
run: cargo build --verbose --release --target ${{ matrix.platform.target }}
- name: Rename binary
run: |
cd target/${{ matrix.platform.target }}/release
mv codeprompt${{ matrix.platform.target == 'x86_64-pc-windows-msvc' && '.exe' || '' }} codeprompt-${{ matrix.platform.release_for }}${{ matrix.platform.target == 'x86_64-pc-windows-msvc' && '.exe' || '' }}
- name: Generate SHA256 checksum
shell: bash
run: |
cd target/${{ matrix.platform.target }}/release
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
powershell -Command "(Get-FileHash codeprompt-${{ matrix.platform.release_for }}.exe -Algorithm SHA256).Hash.ToLower() + ' codeprompt-${{ matrix.platform.release_for }}.exe'" > codeprompt-${{ matrix.platform.release_for }}.sha256
elif [[ "${{ matrix.platform.os }}" == "macos-12" || "${{ matrix.platform.os }}" == "macos-latest" ]]; then
shasum -a 256 codeprompt-${{ matrix.platform.release_for }} > codeprompt-${{ matrix.platform.release_for }}.sha256
else
sha256sum codeprompt-${{ matrix.platform.release_for }} > codeprompt-${{ matrix.platform.release_for }}.sha256
fi
- name: Upload SHA256 checksum
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./target/${{ matrix.platform.target }}/release/codeprompt-${{ matrix.platform.release_for }}.sha256
asset_name: codeprompt-${{ matrix.platform.release_for }}.sha256
asset_content_type: text/plain
- name: Upload Release Asset (Binary)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./target/${{ matrix.platform.target }}/release/codeprompt-${{ matrix.platform.release_for }}${{ matrix.platform.target == 'x86_64-pc-windows-msvc' && '.exe' || '' }}
asset_name: codeprompt-${{ matrix.platform.release_for }}${{ matrix.platform.target == 'x86_64-pc-windows-msvc' && '.exe' || '' }}
asset_content_type: application/octet-stream
upload-templates:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Compress templates directory
run: zip -r templates.zip src/templates
- name: Upload Release Asset (Templates)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./templates.zip
asset_name: templates.zip
asset_content_type: application/zip