-
Notifications
You must be signed in to change notification settings - Fork 6
170 lines (151 loc) · 4.87 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
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
159
160
161
162
163
164
165
166
167
168
169
170
name: Build and Release Pipeline
on:
push:
branches:
- master
jobs:
build-pipeline:
name: "Build ${{ matrix.target }}"
strategy:
matrix:
target:
- aarch64-unknown-linux-gnu
- aarch64-apple-darwin
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- x86_64-unknown-linux-gnu
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04
cross: true
- target: aarch64-apple-darwin
os: macos-13
- target: x86_64-apple-darwin
os: macos-13
- target: x86_64-pc-windows-msvc
os: windows-2022
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Install Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
profile: minimal
target: ${{ matrix.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --locked --target=${{ matrix.target }}
use-cross: ${{ matrix.cross }}
- name: Create Unix Archive
if: ${{ !contains(matrix.target, 'windows') }}
env:
TARGET: ${{ matrix.target }}
srcdir: .
pkgdir: /tmp/pkg
run: |
mkdir -p ${pkgdir}
source scripts/ci/install
tar -czf tpi-${{ matrix.target }}.tar.gz -C ${pkgdir} .
- name: Upload Archive
uses: actions/upload-artifact@v4
if: ${{ !contains(matrix.target, 'windows') }}
with:
name: ${{ matrix.target }}
path: |
tpi-${{ matrix.target }}.tar.gz
- name: Upload Archive (Win)
uses: actions/upload-artifact@v4
if: ${{ contains(matrix.target, 'windows') }}
with:
name: ${{ matrix.target }}
path: |
target/${{ matrix.target }}/release/tpi.exe
debian-packages:
runs-on: ubuntu-latest
needs: build-pipeline
strategy:
matrix:
target:
- aarch64
- x86_64
include:
- target: x86_64
arch: amd64
- target: aarch64
arch: arm64
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.target }}-unknown-linux-gnu
- name: Extract version from Cargo.toml
run: |
VERSION=$(grep '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "PKG_NAME=tpi-$VERSION-${{ matrix.target }}-linux" >> $GITHUB_ENV
- name: Extract tar.gz file
run: |
mkdir ${{ env.PKG_NAME }}
tar -xf tpi-${{ matrix.target }}-unknown-linux-gnu.tar.gz -C ${{ env.PKG_NAME }}
- name: Create DEBIAN package
run: scripts/ci/create_debian_control.sh Cargo.toml ${{ matrix.arch }} ${{ env.PKG_NAME }}
- run: dpkg-deb --build ${{ env.PKG_NAME }}
- name: Upload Archive
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}.deb
path: ${{ env.PKG_NAME }}.deb
try-release:
runs-on: ubuntu-latest
needs: debian-packages
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from Cargo.toml
id: extract_version
run: |
VERSION=$(grep '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Check if tag exists
run: |
if git rev-parse --verify v${VERSION} >/dev/null 2>&1; then
echo "TAG_EXISTS=true" >> $GITHUB_ENV
echo "no new version detected, aborting release Pipeline"
else
echo "TAG_EXISTS=false" >> $GITHUB_ENV
fi
- name: Create new tag
if: ${{ env.TAG_EXISTS == 'false' }}
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "noreply@turingpi.com"
git tag -a "v${{ env.VERSION }}" -m "Release version ${{ env.VERSION }}"
git push origin "v${{ env.VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download artifacts
if: ${{ env.TAG_EXISTS == 'false' }}
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Release
if: ${{ env.TAG_EXISTS == 'false' }}
uses: ncipollo/release-action@v1
with:
name: tpi v${{ env.VERSION }}
tag: v${{ env.VERSION }}
artifacts: artifacts/*
generateReleaseNotes: true