Skip to content

Commit ac8d58c

Browse files
committed
feat: new release workflow
1 parent 6b429c5 commit ac8d58c

13 files changed

Lines changed: 267 additions & 38 deletions

.github/create-release.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# USAGE: ./create-release.sh (major|minor|patch)
4+
5+
# HOWOT: merge all feature branches into dev first
6+
# run this script on dev branch
7+
# create a PR to merge dev into master (will create a new release)
8+
9+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
10+
set -e
11+
12+
echo "Please note: If you did not use this script before, please run ./install-release-tools.sh!"
13+
14+
BUMP="${1:-patch}"
15+
VERSION=$(cat "${DIR}/../VERSION")
16+
NEW_VERSION=$(semver bump "$BUMP" "$VERSION")
17+
18+
if [ -z "$DEBFULLNAME" ]; then
19+
export DEBFULLNAME=`git log -n 1 --pretty=format:%an`
20+
fi
21+
22+
if [ -z "$DEBEMAIL" ]; then
23+
export DEBEMAIL=`git log -n 1 --pretty=format:%ae`
24+
fi
25+
26+
27+
(cd "${DIR}/../src" && dch -v ${NEW_VERSION} --distribution main --force-distribution)
28+
echo -n "$NEW_VERSION" > "${DIR}/../VERSION"
29+
30+
echo "You are ready to commit the new version: git add -A && git commit -m \"chore: release v${NEW_VERSION}\""

.github/imgs/project_logo.png

18.6 KB
Loading

.github/install-release-tools.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
sudo apt-get install -y devscripts
3+
git clone https://github.com/fsaintjacques/semver-tool /tmp/semver
4+
(cd /tmp/semver && sudo make install)

.github/workflows/build-app-nightly.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ env:
1111
STAGING_DIR: /usr/raspberry-build/staging
1212
SYSROOT: /opt/crosstool-ng/x-tools/arm-rpi-linux-gnueabihf/arm-rpi-linux-gnueabihf/sysroot
1313
ROOT_FS: /usr/raspberry-build/rootfs
14-
PKG_VERSION: 0.0.2
1514

1615
jobs:
1716
build-and-package:
@@ -29,6 +28,15 @@ jobs:
2928
path: 'usbproxy'
3029
ref: 'dev'
3130

31+
- uses: actions/checkout@v2
32+
with:
33+
repository: fsaintjacques/semver-tool
34+
path: semver
35+
36+
- name: Build semver utility
37+
run: |
38+
cd semver && make install
39+
3240
- name: Create build directory
3341
run: |
3442
mkdir -p usbproxy/src/build
@@ -60,11 +68,13 @@ jobs:
6068
DESTDIR=${ROOT_FS} make install
6169
6270
# TODO: move the devscripts installation into docker container image build
63-
- name: Change the package version to reflect an nightly build
64-
working-directory: usbproxy/src
71+
- name: Change the package version to reflect a nightly build
72+
working-directory: usbproxy
6573
run: |
74+
VERSION=$(cat ./VERSION)
75+
NEW_VERSION=$(semver bump patch $VERSION)
6676
apt-get install -y devscripts
67-
dch -v ${PKG_VERSION}~$(date +%s)-${GITHUB_SHA}-${GITHUB_RUN_NUMBER} --distribution nightly "$(git log -1 --pretty=%B)" --force-distribution
77+
cd ./src && dch -v ${NEW_VERSION}~$(date +%s)-${GITHUB_SHA}-${GITHUB_RUN_NUMBER} --distribution nightly "$(git log -1 --pretty=%B)" --force-distribution
6878
6979
- name: Build the debian package
7080
working-directory: usbproxy/src
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
on:
2+
push:
3+
paths:
4+
- 'VERSION'
5+
branches: master
6+
7+
jobs:
8+
build-and-package:
9+
name: Build nesto-usbproxy debian package
10+
runs-on: ubuntu-latest
11+
container:
12+
image: ghcr.io/${{ github.repository_owner }}/nesto-usbproxy-deps:latest
13+
credentials:
14+
username: ${{ github.repository_owner }}
15+
password: ${{ secrets.CR_PAT }}
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
with:
20+
path: 'usbproxy'
21+
ref: 'dev'
22+
23+
- uses: actions/checkout@v2
24+
with:
25+
repository: fsaintjacques/semver-tool
26+
path: semver
27+
28+
- name: Build semver utility
29+
run: |
30+
cd semver && make install
31+
32+
- name: Create build directory
33+
run: |
34+
mkdir -p usbproxy/src/build
35+
36+
- name: Create Makefiles using CMake
37+
working-directory: usbproxy/src/build
38+
run: |
39+
LDFLAGS="-L${STAGING_DIR}/usr/local/lib" \
40+
CFLAGS="-I${STAGING_DIR}/usr/local/include" \
41+
CXXFLAGS=$CFLAGS \
42+
PKG_CONFIG_PATH=$STAGING_DIR/usr/local/lib/pkgconfig \
43+
cmake \
44+
"-DCMAKE_PREFIX_PATH=$STAGING_DIR/usr/local" \
45+
"-DCMAKE_FIND_ROOT_PATH=$STAGING_DIR" \
46+
"-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN_FILE" \
47+
"-DCMAKE_INSTALL_PREFIX=/usr" \
48+
"-DCMAKE_BUILD_TYPE=Release" \
49+
"-DUSE_LIBUSB1=1" \
50+
..
51+
52+
- name: Run make
53+
working-directory: usbproxy/src/build
54+
run: |
55+
make
56+
57+
- name: Run make install
58+
working-directory: usbproxy/src/build
59+
run: |
60+
DESTDIR=${ROOT_FS} make install
61+
62+
- name: Read the package version
63+
working-directory: usbproxy
64+
id: version
65+
run: |
66+
NEW_VERSION=$(cat ./VERSION)
67+
echo "::set-output name=NEW_VERSION::$NEW_VERSION"
68+
69+
- name: Build the debian package
70+
working-directory: usbproxy/src
71+
run: |
72+
dpkg-buildpackage -d -aarmhf -tarm-rpi-linux-gnueabihf
73+
74+
- name: Archive production artifacts
75+
uses: actions/upload-artifact@v2
76+
with:
77+
name: debian-package
78+
path: |
79+
usbproxy/*.deb
80+
81+
- name: Push a new tag
82+
id: tag_version
83+
uses: mathieudutour/github-tag-action@v5.1
84+
with:
85+
github_token: ${{ secrets.GITHUB_TOKEN }}
86+
custom_tag: "${{ steps.version.outputs.NEW_VERSION }}"
87+
88+
- name: Create a GitHub release
89+
uses: actions/create-release@v1
90+
id: create_release
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
with:
94+
tag_name: ${{ steps.tag_version.outputs.new_tag }}
95+
release_name: Release ${{ steps.tag_version.outputs.new_tag }}
96+
body: "Signed-off-by: ${{ github.actor }}"
97+
98+
- name: Compress the release asset
99+
run: |
100+
tar -cvjSf nesto-usbproxy_${{ steps.version.outputs.NEW_VERSION }}_armhf.tar.bz2 usbproxy/nesto-usbproxy_${{ steps.version.outputs.NEW_VERSION }}_armhf.deb
101+
102+
- name: Upload Release Asset - Debian Package
103+
uses: actions/upload-release-asset@v1
104+
id: upload-release-asset
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
with:
108+
upload_url: ${{ steps.create_release.outputs.upload_url }}
109+
asset_path: usbproxy/nesto-usbproxy_${{ steps.version.outputs.NEW_VERSION }}_armhf.deb
110+
asset_name: nesto-usbproxy_${{ steps.version.outputs.NEW_VERSION }}_armhf.deb
111+
asset_content_type: application/vnd.debian.binary-package
112+
113+
- name: Upload Release Asset - Archive
114+
uses: actions/upload-release-asset@v1
115+
id: upload-release-asset-archive
116+
env:
117+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118+
with:
119+
upload_url: ${{ steps.create_release.outputs.upload_url }}
120+
asset_path: nesto-usbproxy_${{ steps.version.outputs.NEW_VERSION }}_armhf.tar.bz2
121+
asset_name: nesto-usbproxy_${{ steps.version.outputs.NEW_VERSION }}_armhf.tar.bz2
122+
asset_content_type: application/vnd.debian.binary-package
123+
124+
upload-package:
125+
name: Upload nesto-usbproxy debian package into nesto repository in S3
126+
runs-on: ubuntu-latest
127+
needs: build-and-package
128+
container:
129+
image: ghcr.io/${{ github.repository_owner }}/aptly:latest
130+
credentials:
131+
username: ${{ github.repository_owner }}
132+
password: ${{ secrets.CR_PAT }}
133+
134+
steps:
135+
- name: Download debian package from artifacts
136+
uses: actions/download-artifact@v2
137+
with:
138+
name: debian-package
139+
140+
- name: Add package to aptly
141+
env:
142+
APTLY_REPO: nesto-pos-adapter-devel
143+
run: |
144+
aptly repo add $APTLY_REPO nesto-usbproxy_*_armhf.deb
145+
146+
- name: Prepare GPG private key password
147+
env:
148+
GPG_PRIVATE_KEY_PASSWD: ${{ secrets.GPG_PRIVATE_KEY_PASSWD }}
149+
run: |
150+
echo $GPG_PRIVATE_KEY_PASSWD > ./key_passwd
151+
152+
- name: Import GPG key
153+
id: import_gpg
154+
uses: crazy-max/ghaction-import-gpg@v3
155+
with:
156+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
157+
passphrase: ${{ secrets.GPG_PRIVATE_KEY_PASSWD }}
158+
159+
- name: Sign and upload to S3
160+
env:
161+
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
162+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
163+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
164+
run: |
165+
aptly publish repo -batch=true -passphrase-file="./key_passwd" -gpg-key="$GPG_KEY_ID" -component=aws -distribution=nightly nesto-pos-adapter-devel s3:nesto-debian-repo-devel:

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @MartinLoeper

README.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
USBProxy
2-
![.github/workflows/build-app-nightly.yaml](https://github.com/nesto-software/USBProxy/workflows/.github/workflows/build-app-nightly.yaml/badge.svg?branch=dev)
1+
USB Proxy for Raspberry Pi (armhf)
32
========
43

4+
<p align="center">
5+
<img src=".github/imgs/project_logo.png">
6+
</p>
7+
8+
![.github/workflows/build-app-nightly.yaml](https://github.com/nesto-software/USBProxy/workflows/.github/workflows/build-app-nightly.yaml/badge.svg?branch=dev)
9+
10+
511
Status
612
------
713
This project is currently being refactored by Nesto.
@@ -17,6 +23,7 @@ You must add AWS credentials at the top of the file in advance.
1723

1824
```bash
1925
#!/bin/bash
26+
set -e
2027

2128
# set AWS credentials to access S3 bucket which hosts the debian repository
2229
ACCESS_KEY_ID=
@@ -38,6 +45,26 @@ sudo apt-get update
3845
sudo apt-get install $PKG_NAME
3946
```
4047

41-
Signature
48+
```bash
49+
#!/bin/bash
50+
set -e
51+
52+
FILE=/tmp/nesto-usbproxy-latest.deb
53+
54+
curl -s https://api.github.com/repos/nesto-software/USBProxy/releases/latest \
55+
| grep "browser_download_url.*deb" \
56+
| cut -d : -f 2,3 \
57+
| tr -d \" \
58+
| wget -qi - -O "$FILE"
59+
60+
sudo dpkg -i "$FILE"
61+
```
62+
63+
| Method | Command |
64+
|:----------|:--------------------------------------------------------------------------------------------------|
65+
| **curl** | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/nesto-software/USBProxy/master/scripts/install-from-release.sh)"` |
66+
| **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/nesto-software/USBProxy/master/scripts/install-from-release.sh)"` |
67+
68+
GPG
4269
---------
43-
<a href="https://keyoxide.org/F1C6636C27019FD0D29307DEAE25CBF30C0DDB0C" rel="Nesto Cloud Operations">![Nesto Cloud Operations](.github/gpg_qr.svg)</a>
70+
<a href="https://keyoxide.org/F1C6636C27019FD0D29307DEAE25CBF30C0DDB0C" rel="Nesto Cloud Operations">![Nesto Cloud Operations](.github/imgs/gpg_qr.svg)</a>

TODO.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.3

0 commit comments

Comments
 (0)