Publish JSON package #83
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}.tar.gz json/ js/ | |
- name: Create release and upload | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: ${{ github.head_ref }}.tar.gz | |
tag: ${{ github.head_ref }} | |
omitBody: true |