-
-
Notifications
You must be signed in to change notification settings - Fork 6
135 lines (134 loc) · 6.13 KB
/
release.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: 🚀 Release Firmware
on:
workflow_dispatch:
inputs:
release-version:
description: 'Release version'
required: true
type: string
release-title:
description: 'Release title'
required: true
type: string
run-name: Release ${{ inputs.release-version }} (${{ inputs.release-title }})
jobs:
build:
if: ${{ github.ref_name == 'master' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Replace version in firmware source
run: |
sed -i 's/VERSION = ".*";/VERSION = "${{ inputs.release-version }}";/' ${{ github.workspace }}/firmware/src/JaamFirmware.cpp
- name: Compile firmware
uses: ./.github/workflows/firmware-compile
- name: Copy bin to upload
run: |
cp -f ${{ github.workspace }}/firmware/.pio/build/firmware/firmware.bin ${{ github.workspace }}/JAAM_${{ inputs.release-version }}.bin
- name: Upload firmware
uses: actions/upload-artifact@v4
with:
name: JAAM_${{ inputs.release-version }}.bin
path: ${{ github.workspace }}/JAAM_${{ inputs.release-version }}.bin
build_lite:
if: ${{ github.ref_name == 'master' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Replace version and build type in firmware source
run: |
sed -i 's/VERSION = ".*";/VERSION = "${{ inputs.release-version }}";/' ${{ github.workspace }}/firmware/src/JaamFirmware.cpp
sed -i 's/#define LITE ./#define LITE 1/' ${{ github.workspace }}/firmware/src/Definitions.h
- name: Compile firmware
uses: ./.github/workflows/firmware-compile
- name: Copy bin to upload
run: |
cp -f ${{ github.workspace }}/firmware/.pio/build/firmware/firmware.bin ${{ github.workspace }}/JAAM_${{ inputs.release-version }}_lite.bin
- name: Upload firmware
uses: actions/upload-artifact@v4
with:
name: JAAM_${{ inputs.release-version }}_lite.bin
path: ${{ github.workspace }}/JAAM_${{ inputs.release-version }}_lite.bin
release_firmware:
needs: [build, build_lite]
runs-on: ubuntu-latest
environment:
name: github-pages
permissions:
contents: write
pages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Replace version in firmware source
run: |
sed -i 's/VERSION = ".*";/VERSION = "${{ inputs.release-version }}";/' ${{ github.workspace }}/firmware/src/JaamFirmware.cpp
- name: Download firmware
uses: actions/download-artifact@v4
with:
name: JAAM_${{ inputs.release-version }}.bin
path: ${{ github.workspace }}/JAAM_${{ inputs.release-version }}.bin
- name: Download firmware lite
uses: actions/download-artifact@v4
with:
name: JAAM_${{ inputs.release-version }}_lite.bin
path: ${{ github.workspace }}/JAAM_${{ inputs.release-version }}_lite.bin
- name: Copy release files to bin folder
run: |
mkdir -p ${{ github.workspace }}/bin/
mkdir -p ${{ github.workspace }}/bin_beta/
cp -f ${{ github.workspace }}/JAAM_${{ inputs.release-version }}.bin/JAAM_${{ inputs.release-version }}.bin ${{ github.workspace }}/bin/${{ inputs.release-version }}.bin
cp -f ${{ github.workspace }}/JAAM_${{ inputs.release-version }}.bin/JAAM_${{ inputs.release-version }}.bin ${{ github.workspace }}/bin_beta/${{ inputs.release-version }}.bin
# Disabled for now
# - name: Leave only 3 recent releases
# run: |
# cd ${{ github.workspace }}/bin/
# ls -tp | grep -v '/$' | tail -n +5 | xargs -I {} rm -- {}
# cd ${{ github.workspace }}/bin_beta/
# ls -tp | grep -v '/$' | tail -n +5 | xargs -I {} rm -- {}
# cd ${{ github.workspace }}
- name: Upload flasher to Github Pages
uses: ./.github/workflows/upload-pages
with:
binary_path: ${{ github.workspace }}/JAAM_${{ inputs.release-version }}.bin/JAAM_${{ inputs.release-version }}.bin
lite_binary_path: ${{ github.workspace }}/JAAM_${{ inputs.release-version }}_lite.bin/JAAM_${{ inputs.release-version }}_lite.bin
version: ${{ inputs.release-version }}
- name: Commit changes
id: commit_changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Release ${{ inputs.release-version }}"
file_pattern: ${{ github.workspace }}/firmware/src/JaamFirmware.cpp ${{ github.workspace }}/bin/ ${{ github.workspace }}/bin_beta/ ${{ github.workspace }}/flasher/
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "${{ github.workspace }}/JAAM_${{ inputs.release-version }}.bin/JAAM_${{ inputs.release-version }}.bin,${{ github.workspace }}/JAAM_${{ inputs.release-version }}_lite.bin/JAAM_${{ inputs.release-version }}_lite.bin"
name: "${{ inputs.release-version }}: ${{ inputs.release-title }}"
commit: ${{ steps.commit_changes.outputs.commit_hash }}
tag: ${{ inputs.release-version }}
generateReleaseNotes: true
allowUpdates: true
makeLatest: true
- name: Merge master -> develop
uses: devmasx/merge-branch@master
with:
type: now
target_branch: develop
head_to_merge: ${{ steps.commit_changes.outputs.commit_hash }}
message: Sync Release ${{ inputs.release-version }} to develop
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Update server bin list
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.CLOUD_SERVER_IP }}
username: ${{ secrets.CLOUD_SERVER_USER }}
key: ${{ secrets.CLOUD_SERVER_SSH_KEY }}
script: |
cd /root/ukraine_alarm_map/deploy/
git fetch --all
git switch master
git pull
bash redeploy_update_server.sh -s '/root/ukraine_alarm_map/bin' -sb '/root/ukraine_alarm_map/bin_beta' -m ${{ secrets.CLOUD_MEMCACHED_HOST }}