-
Notifications
You must be signed in to change notification settings - Fork 2
122 lines (107 loc) · 4.26 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
name: Build, Upload and Release
on:
push:
branches:
- main
- ci/release-binary
tags:
- 'v*'
jobs:
build-and-upload:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker image for AMD64 and ARM64
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile
tags: mumak:latest
push: false
platforms: linux/amd64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
load: true
- name: Run Docker container and extract artifacts (AMD64)
run: |
docker run -e POSTGRES_PASSWORD=password -d --name app mumak:latest
mkdir -p artifacts
docker cp app:/source/target/release/mumak-pg16/usr/share/postgresql/16/extension/mumak.control ./artifacts/
docker cp app:/source/target/release/mumak-pg16/usr/lib/postgresql/16/lib/mumak.so ./artifacts/
SQL_FILE=$(docker exec app sh -c "ls /source/target/release/mumak-pg16/usr/share/postgresql/16/extension/mumak--*.sql")
docker cp "app:$SQL_FILE" ./artifacts/
docker stop app
tar -czvf mumak-artifacts-amd64.tar.gz -C artifacts .
- name: Upload Tarred Artifacts (AMD64)
uses: actions/upload-artifact@v4
with:
name: mumak-artifacts-amd64
path: ./mumak-artifacts-amd64.tar.gz
# - name: Run Docker container and extract artifacts (ARM64)
# run: |
# docker run -e POSTGRES_PASSWORD=password -d --name app-arm mumak:latest
# mkdir -p artifacts-arm
# docker cp app-arm:/source/target/release/mumak-pg16/usr/share/postgresql/16/extension/mumak.control ./artifacts-arm/
# docker cp app-arm:/source/target/release/mumak-pg16/usr/lib/postgresql/16/lib/mumak.so ./artifacts-arm/
# SQL_FILE=$(docker exec app-arm sh -c "ls /source/target/release/mumak-pg16/usr/share/postgresql/16/extension/mumak--*.sql")
# docker cp "app-arm:$SQL_FILE" ./artifacts-arm/
# docker stop app-arm
# tar -czvf mumak-artifacts-arm64.tar.gz -C artifacts-arm .
# - name: Upload Tarred Artifacts (ARM64)
# uses: actions/upload-artifact@v2
# with:
# name: mumak-artifacts-arm64
# path: ./mumak-artifacts-arm64.tar.gz
release:
if: startsWith(github.ref, 'refs/tags/')
needs: build-and-upload
runs-on: ubuntu-latest
steps:
- name: Download Tarred Artifacts (AMD64)
uses: actions/download-artifact@v2
with:
name: mumak-artifacts-amd64
# - name: Download Tarred Artifacts (ARM64)
# uses: actions/download-artifact@v2
# with:
# name: mumak-artifacts-arm64
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset (AMD64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mumak-artifacts-amd64.tar.gz
asset_name: mumak-artifacts-amd64.tar.gz
asset_content_type: application/gzip
# - name: Upload Release Asset (ARM64)
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./mumak-artifacts-arm64.tar.gz
# asset_name: mumak-artifacts-arm64.tar.gz
# asset_content_type: application/gzip