-
Notifications
You must be signed in to change notification settings - Fork 9
141 lines (121 loc) · 4.05 KB
/
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
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
name: Build Binaries
on:
push:
tags:
- '*' # Only build on tag pushes for releases
workflow_dispatch: # Allow manual triggering of the build
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
include:
- os: ubuntu-latest
binary_name: sqlwrite-linux.deb
- os: ubuntu-latest
binary_name: sqlwrite-linux.rpm
- os: macos-latest
binary_name: sqlwrite-mac.pkg
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install dependencies
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt-get update
sudo apt-get install -y make curl libcurl4-openssl-dev dpkg-dev rpm
fi
- name: Build with Make
run: make
- name: Package as .deb on Linux
if: matrix.os == 'ubuntu-latest'
run: make deb-package
- name: Package as .rpm on Linux
if: matrix.os == 'ubuntu-latest'
run: make rpm-package
- name: Package as .pkg on macOS
if: matrix.os == 'macos-latest'
run: make pkg
- name: Upload Linux .deb as artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: sqlwrite-linux.deb
path: sqlwrite-linux.deb
- name: Upload Linux .rpm as artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: sqlwrite-linux.rpm
path: sqlwrite-linux.rpm
- name: Upload macOS pkg as artifact
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v3
with:
name: sqlwrite-mac.pkg
path: sqlwrite-mac.pkg
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download Linux .deb artifact
uses: actions/download-artifact@v3
with:
name: sqlwrite-linux.deb
path: .
- name: Download Linux .rpm artifact
uses: actions/download-artifact@v3
with:
name: sqlwrite-linux.rpm
path: .
- name: Download macOS pkg artifact
uses: actions/download-artifact@v3
with:
name: sqlwrite-mac.pkg
path: .
- name: Delete existing release (if any)
run: |
gh release delete "${{ github.ref_name }}" -y || echo "No existing release to delete"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub 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 Linux .deb 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: ./sqlwrite-linux.deb
asset_name: sqlwrite-linux.deb
asset_content_type: application/vnd.debian.binary-package
- name: Upload Linux .rpm 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: ./sqlwrite-linux.rpm
asset_name: sqlwrite-linux.rpm
asset_content_type: application/x-rpm
- name: Upload macOS pkg 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: ./sqlwrite-mac.pkg
asset_name: sqlwrite-mac.pkg
asset_content_type: application/octet-stream