-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (123 loc) · 4.32 KB
/
release.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Build with PyApp, and Release
on:
push:
branches:
- main
tags:
- "v*"
permissions:
contents: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
env:
PYAPP_PROJECT_NAME: 'serverkit-rembg'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Extract PyPi package version
shell: bash
run: |
VERSION=${{ github.ref_name }}
VERSION=${VERSION#v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download PyApp
shell: bash
run: |
curl https://github.com/ofek/pyapp/releases/latest/download/source.tar.gz -Lo pyapp-source.tar.gz
tar -xzf pyapp-source.tar.gz
mv pyapp-v* pyapp-latest
- name: Build executable
env:
PYAPP_PROJECT_VERSION: ${{ env.VERSION }}
PYAPP_PYTHON_VERSION: '3.9'
PYAPP_EXEC_SCRIPT: './main.py'
run: cargo build --release --manifest-path pyapp-latest/Cargo.toml
- name: Archive executable
shell: bash
working-directory: pyapp-latest/target/release
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
EXECUTABLE_NAME=${{ env.PYAPP_PROJECT_NAME }}_${{ runner.os }}_${{ env.VERSION }}.exe
mv pyapp.exe $EXECUTABLE_NAME
tar -czvf ../../../executable-windows.tar.gz $EXECUTABLE_NAME
elif [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
EXECUTABLE_NAME=${{ env.PYAPP_PROJECT_NAME }}_${{ runner.os }}_${{ env.VERSION }}
mv pyapp $EXECUTABLE_NAME
tar -czvf ../../../executable-linux.tar.gz $EXECUTABLE_NAME
elif [ "${{ matrix.os }}" == "macos-latest" ]; then
EXECUTABLE_NAME=${{ env.PYAPP_PROJECT_NAME }}_${{ runner.os }}_${{ env.VERSION }}
mv pyapp $EXECUTABLE_NAME
tar -czvf ../../../executable-macos.tar.gz $EXECUTABLE_NAME
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: executable-${{ runner.os }}
path: executable-*.tar.gz
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: executable-Windows
path: .
- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: executable-Linux
path: .
- name: Download MacOS artifact
uses: actions/download-artifact@v4
with:
name: executable-macOS
path: .
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false
- name: Upload Windows executable 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: ./executable-windows.tar.gz
asset_name: executable-windows.tar.gz
asset_content_type: application/gzip
- name: Upload Linux executable 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: ./executable-linux.tar.gz
asset_name: executable-linux.tar.gz
asset_content_type: application/gzip
- name: Upload MacOS executable 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: ./executable-macos.tar.gz
asset_name: executable-macos.tar.gz
asset_content_type: application/gzip