Skip to content

Commit e03ffa1

Browse files
committed
add ci to generate release zips and render pngs
1 parent 607862c commit e03ffa1

File tree

2 files changed

+153
-0
lines changed

2 files changed

+153
-0
lines changed

.github/workflows/ci.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#
2+
# Copyright (C) 2019-2022 OpenBikeSensor Contributors
3+
# Contact: https://openbikesensor.org
4+
#
5+
# This file is part of the OpenBikeSensor 3D Printable case.
6+
#
7+
# The OpenBikeSensor firmware is free software: you can redistribute it
8+
# and/or modify it under the terms of the GNU Lesser General Public License as
9+
# published by the Free Software Foundation, either version 3 of the License,
10+
# or (at your option) any later version.
11+
#
12+
# OpenBikeSensor firmware is distributed in the hope that it will be
13+
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15+
# General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Lesser General Public License
18+
# along with the OpenBikeSensor firmware. If not, see
19+
# <http://www.gnu.org/licenses/>.
20+
#
21+
name: OpenBikeSensor - CI
22+
on:
23+
# Trigger when pushing in master or pull requests, and when creating
24+
# a pull request.
25+
push:
26+
branches:
27+
- main
28+
- beta
29+
pull_request:
30+
types: [opened, synchronize, reopened]
31+
32+
jobs:
33+
build:
34+
runs-on: ubuntu-latest
35+
container:
36+
# could use a container with sq tools already installed
37+
image: python:3.9
38+
steps:
39+
- uses: actions/checkout@v3
40+
with:
41+
fetch-depth: 0
42+
submodules: recursive
43+
44+
- name: Prepare source
45+
run: |
46+
mkdir -p export
47+
echo GITHUB Ref: ${{ github.ref }}
48+
MAJOR=`cat version.txt|cut -f2 `
49+
if [ "${{ github.ref }}" = "refs/heads/main" ]
50+
then
51+
PATCH=${GITHUB_RUN_NUMBER}
52+
SEPARATOR=.
53+
PREPARE_RELEASE=true
54+
else
55+
PATCH=RC${GITHUB_RUN_NUMBER}
56+
SEPARATOR=-
57+
PREPARE_RELEASE=false
58+
fi
59+
VERSION=${MAJOR}${SEPARATOR}${PATCH}
60+
echo "OBS_PREPARE_RELEASE=${PREPARE_RELEASE}" >> $GITHUB_ENV
61+
echo "OBS_VERSION=${VERSION}" >> $GITHUB_ENV
62+
echo "OBS_MAJOR_VERSION=${MAJOR}" >> $GITHUB_ENV
63+
echo "OBS_OUTPUT_FILENAME=OpenBikeSensor3DPrintableCase-stl-${VERSION}.zip" >>$GITHUB_ENV
64+
echo $VERSION > export/VERSION
65+
echo $VERSION > export/version.txt
66+
echo Building OBS Version: $VERSION
67+
68+
- name: Install build dependencies
69+
run: |
70+
apt-get update
71+
apt-get install -qq -y zip make fonts-open-sans openscad xvfb
72+
73+
- name: Build case
74+
# xvfb-run required for thumbnails
75+
run: |
76+
make clean
77+
xvfb-run -a make -j OPENSCAD_OPTIONS="" all
78+
79+
- name: Package case
80+
run: |
81+
zip --recurse-paths ${{ env.OBS_OUTPUT_FILENAME }} export render
82+
83+
- name: Upload Build Asset
84+
uses: actions/upload-artifact@v2
85+
with:
86+
name: obs-${{ env.OBS_VERSION }}
87+
path: |
88+
export/MainCase/MainCase.stl
89+
if-no-files-found: error
90+
91+
92+
- name: Generate changelog
93+
id: changelog
94+
if: ${{ env.OBS_PREPARE_RELEASE == 'true' }}
95+
uses: metcalfc/[email protected]
96+
with:
97+
myToken: ${{ secrets.GITHUB_TOKEN }}
98+
99+
- name: Create Release
100+
id: create_release
101+
if: ${{ env.OBS_PREPARE_RELEASE == 'true' }}
102+
uses: actions/create-release@v1
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
with:
106+
tag_name: ${{ env.OBS_VERSION }}
107+
release_name: ${{ env.OBS_VERSION }}
108+
body: |
109+
![GitHub downloads](https://img.shields.io/github/downloads-pre/openbikesensor/OpenBikeSensorFirmware/${{ env.OBS_VERSION }}/total) ![GitHub commits since release](https://img.shields.io/github/commits-since/openbikesensor/OpenBikeSensorFirmware/${{ github.sha }}?label=commits%20since%20${{ env.OBS_VERSION }})
110+
111+
Version ${{ env.OBS_VERSION }} based on ${{ github.ref }} ${{ github.sha }}
112+
113+
${{ steps.changelog.outputs.changelog }}
114+
115+
## :tada: Major features and improvements
116+
117+
## :rocket: New features and improvements
118+
119+
## :bug: Bug Fixes
120+
121+
## :ghost: Maintenance
122+
123+
## :construction_worker: Changes for developers / internal
124+
draft: true
125+
prerelease: true
126+
127+
- name: Upload case zip
128+
id: upload-release-asset
129+
if: ${{ env.OBS_PREPARE_RELEASE == 'true' }}
130+
uses: actions/upload-release-asset@v1
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
with:
134+
upload_url: ${{ steps.create_release.outputs.upload_url }}
135+
asset_path: ./${{ env.OBS_OUTPUT_FILENAME }}
136+
asset_name: ${{ env.OBS_OUTPUT_FILENAME }}
137+
asset_content_type: application/zip
138+
139+
- name: Publish preview images
140+
id: push-preview-images
141+
if: ${{ env.OBS_PREPARE_RELEASE == 'true' }}
142+
env:
143+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144+
run: |
145+
echo $env.OBS_VERSION > render/VERSION
146+
echo $env.OBS_VERSION > render/version.txt
147+
date > render/generated.txt
148+
git config user.name github-actions
149+
git config user.email [email protected]
150+
git add render
151+
git commit -m "Generated preview images"
152+
git push

version.txt

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

0 commit comments

Comments
 (0)