-
Notifications
You must be signed in to change notification settings - Fork 1
33 lines (31 loc) · 1.11 KB
/
publish-json.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
name: Publish JSON package
on:
pull_request:
branches:
- main
types:
- closed
workflow_dispatch:
jobs:
build-json-archive:
name: Generate and package JSON files
if: ${{ (github.event.pull_request.merged && startsWith(github.head_ref, 'release-')) || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Target directory
run: mkdir json js
- name: Transform to JSON
run: for f in res/*.yaml; do fn=${f##*/}; yq -o json < $f > json/${fn%.*}.json; done
- name: Transform to JS spec assignment
run: for f in json/*.json; do fn=${f##*/}; echo "const spec = $(cat $f)" > js/${fn%.*}.js; done
- name: Make a release archive
run: tar -czf ${{ github.head_ref || github.ref_name }}.tar.gz json/ js/
- name: Create release and upload
uses: ncipollo/release-action@v1
with:
artifacts: ${{ github.head_ref || github.ref_name }}.tar.gz
tag: ${{ github.head_ref || github.ref_name }}
omitBody: true