Skip to content

Update addons data #649

Update addons data

Update addons data #649

Workflow file for this run

name: Update addons data
on:
push:
branches: main
workflow_dispatch:
inputs:
Version:
required: false
type: string
schedule:
- cron: 30 11/12 * * *
permissions: write-all
jobs:
update:
name: Update
runs-on: ubuntu-20.04
steps:
- name: Clone
uses: actions/[email protected]
with:
repository: ScratchAddons/ScratchAddons
sparse-checkout: |
addons/*/addon.json
addons/addons.json
LICENSE
manifest.json
sparse-checkout-cone-mode: false
fetch-tags: true
fetch-depth: 0
- name: Get version
run: echo "VERSION=${{ inputs.Version || '$(git describe --tags $(git rev-list --tags --max-count=1))' }}" >> "$GITHUB_ENV"
- name: Checkout
run: git checkout "$VERSION"
- name: Setup Node.JS
uses: actions/[email protected]
with:
node-version: 20.6.0
registry-url: "https://registry.npmjs.org"
- name: Check version
id: check_version
run: |
if [[ "v$(npm view @sa-community/addons-data version)" == "$VERSION"* ]]; then
echo "No new version"
echo "stop_workflow=true" >> "$GITHUB_OUTPUT"
else
echo "New version found"
echo "stop_workflow=false" >> "$GITHUB_OUTPUT"
fi
# Setup directory
- name: Checkout
uses: actions/[email protected]
if: steps.check_version.outputs.stop_workflow == 'false'
with:
path: dist
- if: steps.check_version.outputs.stop_workflow == 'false'
run: cp manifest.json dist/manifest.json
- if: steps.check_version.outputs.stop_workflow == 'false'
run: echo $(cat dist/package.json | sed "s/VERSION/$(echo $VERSION | sed 's/v//')/") > dist/package.json
- name: Get addons
if: steps.check_version.outputs.stop_workflow == 'false'
run: |
jq -c 'map(select(startswith("//") | not) | {addonId: ., manifest: (try input catch null)})' addons/addons.json $(jq -r 'map(select(startswith("//") | not) | "addons/" + . + "/addon.json") | join(" ")' addons/addons.json) >> dist/addons.json
- name: Publish
if: steps.check_version.outputs.stop_workflow == 'false'
run: npm publish --provenance --access public
working-directory: dist
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}