-
Notifications
You must be signed in to change notification settings - Fork 3
143 lines (127 loc) · 4.91 KB
/
Copy pathreleases.yml
File metadata and controls
143 lines (127 loc) · 4.91 KB
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
135
136
137
138
139
140
141
142
143
on:
release:
types: [published]
workflow_run:
workflows: ["sdk"]
types: [completed]
branches: [main]
jobs:
check-sdk-status:
runs-on: ubuntu-latest
if: github.event_name == 'release' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
outputs:
should-run: ${{ steps.check.outputs.should-run }}
steps:
- name: Check if workflow should run
id: check
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "should-run=true" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "workflow_run" && "${{ github.event.workflow_run.conclusion }}" == "success" ]]; then
echo "should-run=true" >> $GITHUB_OUTPUT
else
echo "should-run=false" >> $GITHUB_OUTPUT
fi
update-version:
needs: check-sdk-status
if: needs.check-sdk-status.outputs.should-run == 'true'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.VERSION }}
major: ${{ steps.extract.outputs.MAJOR }}
minor: ${{ steps.extract.outputs.MINOR }}
patch: ${{ steps.extract.outputs.PATCH }}
tag: ${{ steps.extract.outputs.TAG }}
type: ${{ steps.release.outputs.TYPE }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Extract version from tag
id: extract
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
TAG="${GITHUB_REF#refs/tags/}"
VERSION="${TAG#v}"
else
TAG="v0.0.0"
VERSION="0.0.0"
fi
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
echo "Extracted version: $VERSION"
echo "MAJOR=$MAJOR" >> $GITHUB_OUTPUT
echo "MINOR=$MINOR" >> $GITHUB_OUTPUT
echo "PATCH=$PATCH" >> $GITHUB_OUTPUT
echo "TAG=$TAG" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Determine release type
id: release
run: |
if [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.prerelease }}" == "true" ]]; then
echo "TYPE=SDK_VERSION_TYPE_PRE_RELEASE" >> $GITHUB_OUTPUT
else
echo "TYPE=SDK_VERSION_TYPE_RELEASE" >> $GITHUB_OUTPUT
fi
publish-to-pio:
needs: update-version
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install platformio
- name: Update library.json version
run: |
echo "Updating version to ${{ needs.update-version.outputs.version }}"
sed -i 's/"version": "[^"]*"/"version": "${{ needs.update-version.outputs.version }}"/' lib/lilka/library.json
cat lib/lilka/library.json
- name: Generate version_auto_gen.h
run: |
cat > lib/lilka/src/lilka/version_auto_gen.h <<EOF
#pragma once
#ifndef VERSION_AUTO_GEN_H
#define VERSION_AUTO_GEN_H
#define SDK_VERSION_MAJOR ${{ needs.update-version.outputs.major }}
#define SDK_VERSION_MINOR ${{ needs.update-version.outputs.minor }}
#define SDK_VERSION_PATCH ${{ needs.update-version.outputs.patch }}
#define SDK_VERSION_TYPE ${{ needs.update-version.outputs.type }}
#endif // VERSION_AUTO_GEN_H
EOF
echo "Generated version_auto_gen.h:"
cat lib/lilka/src/lilka/version_auto_gen.h
- name: Login to PlatformIO
run: |
pio account login -u "${{ secrets.PIO_USERNAME }}" -p "${{ secrets.PIO_PASSWORD }}"
- name: Publish to PlatformIO Registry
run: |
cd lib/lilka
pio pkg publish --non-interactive
echo "Published to PlatformIO Registry"
github-releases-to-discord:
needs: update-version
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Update library.json version
run: |
echo "Updating version to ${{ needs.update-version.outputs.version }}"
sed -i 's/"version": "[^"]*"/"version": "${{ needs.update-version.outputs.version }}"/' lib/lilka/library.json
- name: Github Releases To Discord
uses: SethCohen/github-releases-to-discord@v1.13.0
with:
webhook_url: ${{ secrets.WEBHOOK_URL }}
color: "2105893"
username: "Release Changelog SDK"
avatar_url: "https://avatars.githubusercontent.com/u/213694258?s=48&v=4"
content: "||@everyone||"
footer_title: "Changelog"
footer_icon_url: "https://avatars.githubusercontent.com/u/213694258?s=48&v=4"
footer_timestamp: true