-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (132 loc) · 4.07 KB
/
build-and-publish.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
name: Build and publish docker image
on:
push:
branches:
- main
jobs:
build:
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
# see #73
- target: aarch64-apple-darwin
# see #74
runner: macos-latest
name: Build binary
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@master
with:
submodules: recursive
fetch-depth: '0'
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
target: ${{ matrix.target }}
- name: Build artifact
uses: actions-rs/cargo@v1
with:
command: build
args: --target ${{ matrix.target }} --release
- name: Debug output
run: |
du '${{ github.workspace }}/target/${{ matrix.target }}/release/chunk-search-rs'
file '${{ github.workspace }}/target/${{ matrix.target }}/release/chunk-search-rs'
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bin_${{ matrix.target }}
path: ${{ github.workspace }}/target/${{ matrix.target }}/release/chunk-search-rs
push_tag:
needs: build
runs-on: ubuntu-latest
name: Push tag
outputs:
new_tag: ${{ steps.bump_version.outputs.new_tag }}
steps:
# to push tag correctly, entire history is needed!!
- uses: actions/checkout@master
with:
submodules: recursive
fetch-depth: '0'
- name: Bump version and push tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: "patch"
WITH_V: true
DEFAULT_BRANCH: "main"
id: bump_version
release:
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-apple-darwin
needs: push_tag
runs-on: ubuntu-latest
name: Release
steps:
- name: Download
uses: actions/download-artifact@v4
id: download
with:
name: bin_${{ matrix.target }}
path: ${{ github.workspace }}
- name: Debug output of downloaded artifact
run: |
find '${{ steps.download.outputs.download-path }}' -type f
- name: Prepare release
run: |
mv ${{ github.workspace }}/chunk-search-rs ${{ github.workspace }}/chunk-search-rs_${{ matrix.target }}
- name: Release
uses: softprops/action-gh-release@v2
with:
files: ${{ github.workspace }}/chunk-search-rs_${{ matrix.target }}
draft: false
prerelease: false
tag_name: ${{ needs.push_tag.outputs.new_tag }}
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-docker-image:
runs-on: ubuntu-latest
env:
image_name: chunk-search-rs
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: '0'
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ env.image_name }}
tags: |
type=sha,prefix=sha-,suffix=,format=short
type=raw,value=latest
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./
file: ./docker/single-target/Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max