Skip to content

Commit 0765bda

Browse files
committed
feat: create first version of release automation
1 parent 843e709 commit 0765bda

1 file changed

Lines changed: 162 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)