-
-
Notifications
You must be signed in to change notification settings - Fork 54
96 lines (82 loc) · 3.18 KB
/
build_and_deploy.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
name: Build and Upload to S3
on:
push:
paths:
- 'Software/**'
branches:
- master
- release
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set Build Env based on Branch
id: set_filename
run: |
if [ "${{ github.ref_name }}" = "release" ]; then
echo "build_env=production" >> "$GITHUB_ENV"
echo "bubble_version=live" >> "$GITHUB_ENV"
elif [ "${{ github.ref_name }}" = "master" ]; then
echo "build_env=staging" >> "$GITHUB_ENV"
echo "bubble_version=test" >> "$GITHUB_ENV"
else
echo "build_env=development" >> "$GITHUB_ENV"
echo "bubble_version=test" >> "$GITHUB_ENV"
fi
- name: Increment Build Number
run: |
response=$(
curl --location --request POST 'https://app.researchanddesire.com/version-${{ env.bubble_version }}/api/1.1/wf/increment-sw-version-ossm' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${{ secrets.BUBBLE_API_KEY }}')
echo "SW_VERSION=$response" >> $GITHUB_ENV
echo "SW_VERSION=$response"
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install PlatformIO Core
run: pip install --upgrade platformio
- name: Build PlatformIO Project
run: |
cd Software
export SW_VERSION="${{ env.SW_VERSION }}" && pio run -e ${{ env.build_env }}
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: firmware-artifact # Ensure this name is unique and correctly referenced
path: ./Software/.pio/build/${{ env.build_env }}/firmware.bin
- name: Cleanup on failure
if: failure()
run: |
curl --location --request POST 'https://app.researchanddesire.com/version-${{ env.bubble_version }}/api/1.1/wf/decrement-sw-version-ossm' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${{ secrets.BUBBLE_API_KEY }}'
upload:
needs: build
runs-on: ubuntu-latest
outputs:
firmware_filename: ${{ steps.set_filename.outputs.firmware_filename }}
steps:
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: firmware-artifact
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Set Filename based on Branch
id: set_filename
run: |
if [ "${{ github.ref_name }}" = "release" ]; then
echo "firmware_filename=firmware.bin" >> "$GITHUB_ENV"
else
echo "firmware_filename=firmware-dev.bin" >> "$GITHUB_ENV"
fi
- name: Upload Binary to S3
run: aws s3 cp ./firmware.bin s3://${{ secrets.AWS_S3_BUCKET_NAME }}/$firmware_filename --acl public-read