Skip to content

Commit 062a0e3

Browse files
Release pipeline rework
Rebuilt the github pipeline: * there is a 'validation pipeline' (build.yml) that runs on every commit ** it verifies the code against clippy, unit-tests, and license validations * a git tag automatically gets created if the version is updated in the Cargo.toml file. * on a git tag, an automated release build is triggered. * binaries are built for all major platforms. * debian packages are automatically created for x86 and amd64
1 parent f9a5d58 commit 062a0e3

File tree

7 files changed

+240
-205
lines changed

7 files changed

+240
-205
lines changed

.github/workflows/auto_tagger.yml

-37
This file was deleted.

.github/workflows/build.yml

+36-83
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
name: Tpi tool CI
1+
name: Tpi Validation Pipeline
22
on: [push]
33
jobs:
4-
clippy_check:
4+
5+
cargo-clippy:
56
runs-on: ubuntu-latest
67
steps:
78
- uses: actions/checkout@v3
@@ -10,99 +11,51 @@ jobs:
1011
with:
1112
token: '${{ secrets.GITHUB_TOKEN }}'
1213
args: '--all-features'
13-
cargo-test:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- uses: actions/checkout@v3
17-
- uses: actions-rs/toolchain@v1
18-
with:
19-
toolchain: stable
20-
default: true
21-
profile: minimal
22-
- uses: actions-rs/cargo@v1
23-
with:
24-
command: test
14+
2515
cargo-deny:
2616
runs-on: ubuntu-latest
2717
steps:
2818
- uses: actions/checkout@v3
2919
- uses: EmbarkStudios/cargo-deny-action@v1
3020
with:
3121
command: check bans licenses sources
32-
target-pipeline:
33-
name: "${{ matrix.target }}"
34-
strategy:
35-
matrix:
36-
target:
37-
- aarch64-unknown-linux-gnu
38-
- aarch64-apple-darwin
39-
- x86_64-apple-darwin
40-
- x86_64-pc-windows-msvc
41-
- x86_64-unknown-linux-gnu
42-
include:
43-
- target: x86_64-unknown-linux-gnu
44-
os: ubuntu-22.04
45-
- target: aarch64-unknown-linux-gnu
46-
os: ubuntu-22.04
47-
cross: true
48-
- target: aarch64-apple-darwin
49-
os: macos-13
50-
- target: x86_64-apple-darwin
51-
os: macos-13
52-
- target: x86_64-pc-windows-msvc
53-
os: windows-2022
54-
runs-on: '${{ matrix.os }}'
22+
23+
cargo-test:
24+
runs-on: ubuntu-latest
25+
needs: cargo-deny
5526
steps:
5627
- uses: actions/checkout@v3
57-
- name: install toolchain
58-
uses: actions-rs/toolchain@v1
28+
with:
29+
fetch-depth: 0
30+
- uses: actions-rs/toolchain@v1
5931
with:
6032
toolchain: stable
6133
default: true
6234
profile: minimal
63-
target: '${{ matrix.target }}'
64-
- name: build
65-
uses: actions-rs/cargo@v1
66-
with:
67-
command: build
68-
args: '--release --locked --target=${{ matrix.target }}'
69-
use-cross: ${{ matrix.cross }}
70-
- name: archive
71-
uses: actions/upload-artifact@v3
35+
- uses: actions-rs/cargo@v1
7236
with:
73-
name: 'build output'
74-
path: |
75-
# workaround to prevent a common ancestor in the files,
76-
# this way we can perserve the folder structure.
77-
.github/workflows/build.yml
78-
target/${{ matrix.target }}/release/tpi
79-
target/${{ matrix.target }}/release/tpi.exe
80-
target/${{ matrix.target }}/release/build/*/out/PKGBUILD
37+
command: test
38+
- name: Extract version from Cargo.toml
39+
id: extract_version
40+
run: |
41+
VERSION=$(grep '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
42+
echo "VERSION=$VERSION" >> $GITHUB_ENV
8143
82-
archive:
83-
name: ${{ matrix.name }} packager
84-
runs-on: ubuntu-latest
85-
needs: target-pipeline
86-
strategy:
87-
matrix:
88-
name:
89-
- debian
90-
- arch
91-
- windows
92-
- macos
93-
steps:
94-
- uses: actions/checkout@v3
95-
- uses: actions/download-artifact@v3
96-
with:
97-
name: 'build output'
98-
- name: running archiver
99-
run: scripts/ci/package.sh ${{ matrix.name }}
100-
- name: archive packages
101-
uses: actions/upload-artifact@v3
102-
with:
103-
name: '${{ matrix.name }} packages'
104-
path: |
105-
target/debian/*
106-
target/arch/*
107-
target/win/*
108-
target/apple/*
44+
- name: Check if tag exists
45+
id: check_tag
46+
run: |
47+
if git rev-parse --verify v${VERSION} >/dev/null 2>&1; then
48+
echo "TAG_EXISTS=true" >> $GITHUB_ENV
49+
else
50+
echo "TAG_EXISTS=false" >> $GITHUB_ENV
51+
fi
52+
53+
- name: Create new tag
54+
if: ${{ env.TAG_EXISTS == 'false' }}
55+
run: |
56+
git config --global user.name "${{ github.actor }}"
57+
git config --global user.email "noreply@turingpi.com"
58+
git tag -a "v${{ env.VERSION }}" -m "Release version ${{ env.VERSION }}"
59+
git push origin "v${{ env.VERSION }}"
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Release Pipeline
2+
on:
3+
push:
4+
tags:
5+
- 'v[0-9]+.[0-9]+.[0-9]+'
6+
jobs:
7+
8+
build-pipeline:
9+
name: "Build ${{ matrix.target }}"
10+
strategy:
11+
matrix:
12+
target:
13+
- aarch64-unknown-linux-gnu
14+
- aarch64-apple-darwin
15+
- x86_64-apple-darwin
16+
- x86_64-pc-windows-msvc
17+
- x86_64-unknown-linux-gnu
18+
include:
19+
- target: x86_64-unknown-linux-gnu
20+
os: ubuntu-22.04
21+
- target: aarch64-unknown-linux-gnu
22+
os: ubuntu-22.04
23+
cross: true
24+
- target: aarch64-apple-darwin
25+
os: macos-13
26+
- target: x86_64-apple-darwin
27+
os: macos-13
28+
- target: x86_64-pc-windows-msvc
29+
os: windows-2022
30+
31+
runs-on: ${{ matrix.os }}
32+
steps:
33+
- name: Checkout Code
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 1
37+
38+
- name: Install Toolchain
39+
uses: actions-rs/toolchain@v1
40+
with:
41+
toolchain: stable
42+
default: true
43+
profile: minimal
44+
target: ${{ matrix.target }}
45+
46+
- name: Build
47+
uses: actions-rs/cargo@v1
48+
with:
49+
command: build
50+
args: --release --locked --target=${{ matrix.target }}
51+
use-cross: ${{ matrix.cross }}
52+
53+
- name: Create Unix Archive
54+
if: ${{ !contains(matrix.target, 'windows') }}
55+
env:
56+
TARGET: ${{ matrix.target }}
57+
srcdir: .
58+
pkgdir: /tmp/pkg
59+
run: |
60+
mkdir -p ${pkgdir}
61+
source scripts/ci/install
62+
tar -czf tpi-${{ matrix.target }}.tar.gz -C ${pkgdir} .
63+
64+
- name: Upload Archive
65+
uses: actions/upload-artifact@v4
66+
if: ${{ !contains(matrix.target, 'windows') }}
67+
with:
68+
name: ${{ matrix.target }}
69+
path: |
70+
tpi-${{ matrix.target }}.tar.gz
71+
72+
- name: Upload Archive (Win)
73+
uses: actions/upload-artifact@v4
74+
if: ${{ contains(matrix.target, 'windows') }}
75+
with:
76+
name: ${{ matrix.target }}
77+
path: |
78+
target/${{ matrix.target }}/release/tpi.exe
79+
80+
debian-packages:
81+
runs-on: ubuntu-latest
82+
needs: build-pipeline
83+
strategy:
84+
matrix:
85+
target:
86+
- aarch64
87+
- x86_64
88+
include:
89+
- target: x86_64
90+
arch: amd64
91+
- target: aarch64
92+
arch: arm64
93+
steps:
94+
- name: Checkout Code
95+
uses: actions/checkout@v4
96+
with:
97+
fetch-depth: 0
98+
99+
- uses: actions/download-artifact@v4
100+
with:
101+
name: ${{ matrix.target }}-unknown-linux-gnu
102+
103+
- name: Extract version from Cargo.toml
104+
run: |
105+
VERSION=$(grep '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
106+
echo "VERSION=$VERSION" >> $GITHUB_ENV
107+
echo "PKG_NAME=tpi-$VERSION-${{ matrix.target }}-linux" >> $GITHUB_ENV
108+
109+
- name: Extract tar.gz file
110+
run: |
111+
mkdir ${{ env.PKG_NAME }}
112+
tar -xf tpi-${{ matrix.target }}-unknown-linux-gnu.tar.gz -C ${{ env.PKG_NAME }}
113+
114+
- name: Create DEBIAN package
115+
run: scripts/ci/create_debian_control.sh Cargo.toml ${{ matrix.arch }} ${{ env.PKG_NAME }}
116+
117+
- run: dpkg-deb --build ${{ env.PKG_NAME }}
118+
119+
- name: Upload Archive
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: ${{ env.PKG_NAME }}.deb
123+
path: ${{ env.PKG_NAME }}.deb
124+
125+
create_release:
126+
needs: debian-packages
127+
runs-on: ubuntu-latest
128+
steps:
129+
- name: Checkout Code
130+
uses: actions/checkout@v4
131+
- name: Extract version from Cargo.toml
132+
run: |
133+
VERSION=$(grep '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
134+
echo "VERSION=$VERSION" >> $GITHUB_ENV
135+
136+
- name: Download artifacts
137+
uses: actions/download-artifact@v4
138+
with:
139+
path: artifacts
140+
merge-multiple: true
141+
142+
- name: Release
143+
uses: ncipollo/release-action@v1
144+
with:
145+
name: tpi v${{ env.VERSION }}
146+
tag: ${{ env.VERSION }}
147+
artifacts: artifacts/*
148+
generateReleaseNotes: true

Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "tpi"
33
version = "1.0.6"
44
edition = "2021"
55
license = "Apache-2.0"
6-
authors = ["Sven Rademakers <sven@turingpi.com>", "Ruslan Akbashev <ra@turingpi.com>"]
6+
authors = ["Sven Rademakers <sven@turingpi.com>"]
77
description = "Official Turing-Pi2 CLI tool"
88
homepage = "https://turingpi.com/"
99
repository = "https://github.com/turing-machines/tpi"
@@ -35,3 +35,7 @@ url = "2.5.2"
3535
default = ["reqwest/rustls-tls"]
3636
native-tls = ["reqwest/native-tls"]
3737
localhost = []
38+
39+
[profile.release]
40+
lto = true
41+
strip = true

scripts/ci/create_debian_control.sh

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2023 Turing Machines
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
#!/bin/bash
16+
toml_file=${1}
17+
arch=${2}
18+
output_dir=${3:-$(pwd)}
19+
20+
if [ -z "$2" ]; then
21+
echo "missing architecture argument" >&2
22+
exit -1
23+
fi
24+
25+
if [ ! -f "${toml_file}" ]; then
26+
echo "provided toml file: ${toml_file}, does not exist" >&2
27+
exit -1
28+
fi
29+
30+
PACKAGE_NAME=$(grep '^name =' ${toml_file} | sed 's/name = "\(.*\)"/\1/')
31+
VERSION=$(grep '^version =' ${toml_file} | sed 's/version = "\(.*\)"/\1/')
32+
MAINTAINER=$(grep '^authors =' ${toml_file} | sed 's/authors = \[\s*"\(.*\)\s*"\]/\1/')
33+
DESCRIPTION=$(grep '^description =' ${toml_file} | sed 's/description = "\(.*\)"/\1/')
34+
35+
mkdir -p ${output_dir}/DEBIAN/
36+
cat <<EOL > "${output_dir}/DEBIAN/control"
37+
Package: $PACKAGE_NAME
38+
Version: $VERSION
39+
Section: base
40+
Priority: optional
41+
Architecture: ${arch}
42+
Maintainer: $MAINTAINER
43+
Description: $DESCRIPTION
44+
EOL
45+

0 commit comments

Comments
 (0)