forked from MarlinFirmware/Marlin
-
Notifications
You must be signed in to change notification settings - Fork 4
100 lines (97 loc) · 4.25 KB
/
nightly.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
name: Nightly
on:
repository_dispatch:
types: trigger-nightly
schedule:
- cron: '0 2 * * *' # run at 2 AM UTC
jobs:
merge:
strategy:
fail-fast: false
matrix:
branch: [bugfix-2.0.x, 2.0.x, bugfix-2.0.x-bltouch]
runs-on: ubuntu-latest
steps:
- name: Check out ${{ matrix.branch }}
uses: actions/checkout@v2
with:
ref: ${{ matrix.branch }}
- name: Merge ${{ matrix.branch }}
id: merge
run: |
git fetch --tags --force
BRANCH=${{ matrix.branch }}
MERGE_BRANCH=$(printf '%s\n' "${BRANCH//-bltouch/}")
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git fetch --unshallow
git pull https://github.com/MarlinFirmware/Marlin $MERGE_BRANCH
DATE="$(date '+%Y/%m/%d')"
VERSION_NAME=$(less "Marlin/src/inc/Version.h"| grep "#define SHORT_BUILD_VERSION" | awk -F\" '{ print $2 }')
VERSION_NAME=$(if [[ "${{ matrix.branch }}" == *"-bltouch" ]]; then echo "${VERSION_NAME}-bltouch"; else echo "$VERSION_NAME"; fi)
TAG_NAME=$(if [[ "${{ matrix.branch }}" == "2.0.x"* ]]; then echo "v$VERSION_NAME"; else echo "nightly-${{ matrix.branch }}-$(date '+%Y/%m/%d')"; fi)
PRERELEASE=$(if [[ "${{ matrix.branch }}" == "2.0.x"* ]]; then echo false; else echo true; fi)
TAG_EXISTED=$(if [ $(git tag -l $TAG_NAME) ]; then echo true; else echo false; fi)
RELEASE_NAME=$(if [[ "${{ matrix.branch }}" == "2.0.x"* ]]; then echo "$VERSION_NAME"; else echo "Nighly Build on ${{ matrix.branch }} ($DATE)"; fi)
echo "TAG_NAME=$TAG_NAME"
echo "TAG_EXISTED=$TAG_EXISTED"
echo "##[set-output name=merge_branch_name;]$MERGE_BRANCH"
echo "##[set-output name=tag_existed;]$TAG_EXISTED"
echo "##[set-output name=prerelease;]$PRERELEASE"
echo "##[set-output name=version_name;]$VERSION_NAME"
echo "##[set-output name=tag_name;]$TAG_NAME"
echo "##[set-output name=date;]$DATE"
echo "##[set-output name=release_name;]$RELEASE_NAME"
- name: Set up Python
if: steps.merge.outputs.tag_existed == 'false'
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install pip
if: steps.merge.outputs.tag_existed == 'false'
run: |
python -m pip install --upgrade pip
- name: Build Marlin
if: steps.merge.outputs.tag_existed == 'false'
run: |
pip install platformio
./buildroot/bin/generate_version
platformio run
cd .pio/build/STM32F103RC_btt_512K/
mkdir artifacts
mv firmware.bin artifacts/
- name: Create and Push Tag ${{ steps.merge.outputs.tag_name }}
if: steps.merge.outputs.tag_existed == 'false'
run: |
MESSAGE=$(if [[ "${{ steps.merge.outputs.tag_name }}" == v* ]]; then echo "Release ${{ steps.merge.outputs.version_name }}"; else echo "Nightly build at ${{ steps.merge.outputs.date }} on ${{ matrix.branch }}"; fi)
git tag -a "${{ steps.merge.outputs.tag_name }}" -m "$MESSAGE"
git push --follow-tags
- name: Upload firmware
if: steps.merge.outputs.tag_existed == 'false'
uses: actions/[email protected]
with:
name: firmware
path: .pio/build/STM32F103RC_btt_512K/artifacts
- name: Create Release
if: steps.merge.outputs.tag_existed == 'false'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.merge.outputs.tag_name }}
release_name: ${{ steps.merge.outputs.release_name }}
draft: false
prerelease: ${{ steps.merge.outputs.prerelease }}
body: "[firmware.bin](https://github.com/crysxd/Marlin/releases/download/${{ github.ref }}/firmware.bin)"
- name: Upload Release Asset
if: steps.merge.outputs.tag_existed == 'false'
id: upload-release-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: .pio/build/STM32F103RC_btt_512K/artifacts/firmware.bin
asset_name: firmware.bin
asset_content_type: application/zip