-
Notifications
You must be signed in to change notification settings - Fork 4
121 lines (113 loc) · 4.03 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
# yamllint disable rule:line-length rule:truthy
---
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install jq
run: sudo apt-get install -y jq rpm
- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install Cargo Deb
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-deb
- name: Install Cargo Rpm
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-rpm
- name: Build Debian Package
uses: actions-rs/cargo@v1
with:
command: deb
- name: Build Rpm Package
uses: actions-rs/cargo@v1
with:
command: rpm
args: build
- name: Build Static Linux Binary
uses: gmiam/rust-musl-action@master
with:
args: cargo build --target x86_64-unknown-linux-musl --release --features app
- 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: Gather Debian Package Filename
id: deb_pkg_filename
run: |
export DEB_PKG_VERSION=$(echo ${{ github.ref }} | sed 's|^refs/tags/v||')
export DEB_PKG_VERSION=$(cargo read-manifest | jq -r .version | sed 's/-/~/')
echo ::set-output name=filename::mhost_${DEB_PKG_VERSION}_amd64.deb
- name: Upload Debian Package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/debian/${{ steps.deb_pkg_filename.outputs.filename }}
asset_name: ${{ steps.deb_pkg_filename.outputs.filename }}
asset_content_type: application/octet-stream
- name: Gather Rpm Package Filename
id: rpm_pkg_filename
run: |
export RPM_PKG_FILENAME=$(ls -1 ./target/release/rpmbuild/RPMS/x86_64/ | head -1)
echo ::set-output name=filename::${RPM_PKG_FILENAME}
- name: Upload Rpm Package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/release/rpmbuild/RPMS/x86_64/${{ steps.rpm_pkg_filename.outputs.filename }}
asset_name: ${{ steps.rpm_pkg_filename.outputs.filename }}
asset_content_type: application/octet-stream
- name: Upload Static Linux Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/x86_64-unknown-linux-musl/release/mhost
asset_name: mhost-linux-musl-x86_64
asset_content_type: application/octet-stream
- name: Gather Docker Tag
id: docker_info
run: |
export DOCKER_TAG=$(echo ${{ github.ref }} | sed 's|^refs/tags/||')
echo ::set-output name=tag::${DOCKER_TAG}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v2
with:
context: distribution/docker
push: true
tags: |
lukaspustina/mhost:${{ steps.docker_info.outputs.tag }}
lukaspustina/mhost:latest
build-args: |
RELEASE_TAG=${{ steps.docker_info.outputs.tag }}