-
-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (129 loc) · 5.13 KB
/
release-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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Release Build
on:
workflow_dispatch:
inputs:
version:
description: 'Version number (e.g. 0.1.0)'
required: true
jobs:
get_build_number:
runs-on: ubuntu-22.04
outputs:
build_number: ${{ steps.set_number.outputs.build_number }}
steps:
- name: Generate build number
id: set_number
run: |
echo "build_number=$(( $GITHUB_RUN_NUMBER ))" >> $GITHUB_OUTPUT
build-x86_64:
needs: get_build_number
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Change Cargo.toml version
run: |
VERSION="${{ github.event.inputs.version }}-build${{ needs.get_build_number.outputs.build_number }}"
sed -i "s/^version[ ]*=[ ]*\"[^\"]*\"/version = \"${VERSION}\"/" Cargo.toml
echo "Updated version in Cargo.toml:"
grep "^version" Cargo.toml
- name: Build
run: cargo build --release --target x86_64-unknown-linux-gnu
- name: Strip binary
run: strip target/x86_64-unknown-linux-gnu/release/komandan
- name: Create Release Tag
run: |
TAG="v${{ github.event.inputs.version }}-build${{ needs.get_build_number.outputs.build_number }}"
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
- name: Zip artifact
run: zip -j komandan_${{ env.RELEASE_TAG }}-linux-x86_64.zip target/x86_64-unknown-linux-gnu/release/komandan
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-x86_64-artifact
path: |
komandan_${{ env.RELEASE_TAG }}-linux-x86_64.zip
build-aarch64:
needs: get_build_number
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Change Cargo.toml version
run: |
VERSION="${{ github.event.inputs.version }}-build${{ needs.get_build_number.outputs.build_number }}"
sed -i "s/^version[ ]*=[ ]*\"[^\"]*\"/version = \"${VERSION}\"/" Cargo.toml
echo "Updated version in Cargo.toml:"
grep "^version" Cargo.toml
- name: Add target aarch64-unknown-linux-gnu
run: rustup target add aarch64-unknown-linux-gnu
- name: Install aarch64-linux-gnu-gcc
run: sudo apt update && sudo apt install -y gcc-aarch64-linux-gnu
- name: Build
run: cargo build --features vendored-openssl --release --target aarch64-unknown-linux-gnu
- name: Strip binary
run: aarch64-linux-gnu-strip target/aarch64-unknown-linux-gnu/release/komandan
- name: Create Release Tag
run: |
TAG="v${{ github.event.inputs.version }}-build${{ needs.get_build_number.outputs.build_number }}"
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
- name: Zip artifact
run: zip -j komandan_${{ env.RELEASE_TAG }}-linux-aarch64.zip target/aarch64-unknown-linux-gnu/release/komandan
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-aarch64-artifact
path: |
komandan_${{ env.RELEASE_TAG }}-linux-aarch64.zip
release:
runs-on: ubuntu-22.04
needs: [get_build_number, build-x86_64, build-aarch64]
permissions:
contents: write
steps:
- name: Download artifact x86_64
uses: actions/download-artifact@v4
with:
name: build-x86_64-artifact
- name: Download artifact aarch64
uses: actions/download-artifact@v4
with:
name: build-aarch64-artifact
- name: Create Release Tag
run: |
TAG="v${{ github.event.inputs.version }}-build${{ needs.get_build_number.outputs.build_number }}"
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.RELEASE_TAG }}
name: ${{ env.RELEASE_TAG }}
body: Release ${{ env.RELEASE_TAG }}
artifacts: |
komandan_${{ env.RELEASE_TAG }}-linux-x86_64.zip
komandan_${{ env.RELEASE_TAG }}-linux-aarch64.zip
docker-build-and-push:
runs-on: ubuntu-22.04
needs: [get_build_number, release]
steps:
- uses: actions/checkout@v4
- name: Get version
run: |
VERSION="${{ github.event.inputs.version }}-build${{ needs.get_build_number.outputs.build_number }}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Change Cargo.toml version
run: |
sed -i "s/^version[ ]*=[ ]*\"[^\"]*\"/version = \"${{ env.VERSION }}\"/" Cargo.toml
echo "Updated version in Cargo.toml:"
grep "^version" Cargo.toml
- name: Build Docker image
run: docker build -t hahnavi/komandan:${{ env.VERSION }} .
- name: Retag image
run: docker tag hahnavi/komandan:${{ env.VERSION }} hahnavi/komandan:latest
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Push Docker images
run: |
docker push hahnavi/komandan:${{ env.VERSION }}
docker push hahnavi/komandan:latest