-
Notifications
You must be signed in to change notification settings - Fork 21
149 lines (140 loc) · 6.6 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
on:
push:
branches: [main]
name: Create LedFx-Frontend Release
jobs:
build:
name: Build & Release
if: "startsWith(github.event.head_commit.message, 'Release') || startsWith(github.event.head_commit.message, 'Beta')"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get commit-messages
id: get_messages
run: |
git log --pretty=format:"+ %s [\![by](https://img.shields.io/badge/by-$(echo '%an' | sed 's/ /_/g')-blue.svg?logo=github&logoColor=white)](https://github.com/YeonV/LedFx-Frontend-v2/commit/%h)" $(git describe --tags --abbrev=0 @^)..@ | grep -v -E '(cleanup|Update)' | awk '{ sub(/\[\[!\]\]/, ""); msg = substr($0, 1, index($0, "[!") - 1); if (length(msg) >= 5 && !seen[msg]++) { print $0 } }' | awk '{ while (match($0, /https:\/\/img\.shields\.io\/badge\/by-[^"]*-blue\.svg\?logo=github&logoColor=white/)) { url = substr($0, RSTART, RLENGTH); gsub(" ", "_", url); printf "%s%s", substr($0, 1, RSTART - 1), url; $0 = substr($0, RSTART + RLENGTH) } gsub(" ", "_", $0); print }' >> /tmp/messages.txt
cp /tmp/messages.txt .messages.md
cat /tmp/messages.txt
echo 'MESSAGES<<EOF' >> $GITHUB_ENV
printf '%b\n' "$(cat /tmp/messages.txt)" >> $GITHUB_ENV
echo EOF >> $GITHUB_ENV
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
# - name: Dispatch Build
# run: |
# curl -XPOST -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{secrets.FRONTEND_TOKEN}}" https://api.github.com/repos/YeonV/LedFx-Builds/actions/workflows/build-ledfx.yml/dispatches --data '{"fversion": "${{ steps.package-version.outputs.current-version}}"}'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Node Modules
run: |
yarn install
- name: Build project
env:
release_version: ${{ steps.package-version.outputs.current-version}}
REACT_APP_VERSION: ${{ steps.package-version.outputs.current-version}}
run: yarn build
- name: Preparing Archive
run: |
mv build ledfx_frontend_v2
printf "${{ env.MESSAGES }}" >> ledfx_frontend_v2/messages.md
- name: Create Archive
uses: thedoctor0/zip-release@master
with:
filename: 'ledfx_frontend_v2.zip'
path: 'ledfx_frontend_v2'
exclusions: '*.git* /*node_modules/* .editorconfig'
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# tag_name: ${{ github.ref }}
# release_name: Release ${{ github.ref }}
tag_name: ${{ steps.package-version.outputs.current-version}}
release_name: Release ${{ steps.package-version.outputs.current-version}}
body: |
${{ env.MESSAGES }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./ledfx_frontend_v2.zip
asset_name: ledfx_frontend_v2.zip
asset_content_type: application/zip
- name: Prepare Trigger
id: get-id
run: |
id=$(echo ${{steps.package-version.outputs.current-version}} | cut -d. -f3)
echo "::set-output name=id::$id"
- name: Trigger Build
uses: benc-uk/workflow-dispatch@v1
with:
workflow: LedFx BuildPipeline UV
# workflow: LedFx BuildPipeline
repo: YeonV/LedFx-Builds
token: ${{ secrets.FRONTEND_TOKEN }}
inputs: '{ "fversion": "${{ steps.get-id.outputs.id}}", "release": "${{ startsWith(github.event.head_commit.message, ''Beta'') && ''No'' || ''Yes'' }}" }'
# - name: 📂 Sync files
# continue-on-error: true
# uses: SamKirkland/FTP-Deploy-Action@2.0.0
# env:
# FTP_SERVER: ${{ secrets.FTP_SERVER }}
# FTP_USERNAME: ${{ secrets.FTP_USERNAME }}
# FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
# PORT: 22
# METHOD: sftp
# LOCAL_DIR: ./ledfx_frontend_v2/
# REMOTE_DIR: ./preview.ledfx.app/
- name: Build project Hass
env:
release_version: ${{ steps.package-version.outputs.current-version}}
REACT_APP_VERSION: ${{ steps.package-version.outputs.current-version}}
run: yarn buildhass
- name: Preparing Archive
run: |
mv build ledfx_frontend_hass
printf "${{ env.MESSAGES }}" >> ledfx_frontend_hass/messages.md
- name: Create Archive
uses: thedoctor0/zip-release@master
with:
filename: 'ledfx_frontend_hass.zip'
path: 'ledfx_frontend_hass'
exclusions: '*.git* /*node_modules/* .editorconfig'
- name: Upload Release Asset Hass
id: upload-release-asset-hass
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./ledfx_frontend_hass.zip
asset_name: ledfx_frontend_hass.zip
asset_content_type: application/zip
# - name: Prepare Trigger Hass
# id: hass
# run: |
# id=$(echo ${{steps.package-version.outputs.current-version}} | cut -d. -f1,2,3)
# echo "::set-output name=id::$id"
# - name: Trigger Hass
# uses: benc-uk/workflow-dispatch@v1
# with:
# workflow: Builder
# repo: YeonV/home-assistant-addons
# ref: refs/heads/master
# token: ${{ secrets.LEDFX_HOMEASSISTANT_ADDON }}
# inputs: '{ "version": "${{ steps.hass.outputs.id}}" }'