Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split registry publish to composite action #166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/actions/registry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: registry
description: Publish plug-in to DITA-OT plug-in registry

inputs:
TOKEN:
required: true
description: Github token
CHKSUM:
required: true
description: SHA-256 of the distribution file
VERSION:
required: true
description: Plug-in version
PLUGIN_NAME:
required: true
description: Plug-in ID
URL:
required: true
description: Plug-in download URL
FORK:
required: true
description: Registry repo fork

runs:
using: 'composite'
steps:
- name: Check out registry
uses: actions/checkout@v3
with:
repository: dita-ot/registry
path: registry
- name: Update registry
working-directory: registry
run: |
cat ${{ inputs.PLUGIN_NAME }}.json \
| jq '.[length -1]' \
| jq --arg url "${{ inputs.URL }}" '. | .url|=$url' \
| jq --arg chksum "${{ inputs.CHKSUM }}" '. | .cksum|=$chksum' \
| jq --arg vers "${{ inputs.VERSION }}" '. | .vers|=$vers' > buf.json
jq '. += [input]' ${{ inputs.PLUGIN_NAME }}.json buf.json \
| jq . > concat.json
mv concat.json ${{ inputs.PLUGIN_NAME }}.json
rm buf.json
shell: bash
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
path: registry
token: ${{ inputs.TOKEN }}
push-to-fork: ${{ inputs.FORK }}
branch-suffix: timestamp
commit-message: Add ${{ inputs.PLUGIN_NAME }} ${{ inputs.VERSION }}
title: Add ${{ inputs.PLUGIN_NAME }} ${{ inputs.VERSION }}
body: |
Add plug-in `${{ inputs.PLUGIN_NAME }}` version `${{ inputs.VERSION }}`.

* [Release notes](https://github.com/jelovirt/org.lwdita/releases/tag/${{ inputs.VERSION }})
41 changes: 9 additions & 32 deletions .github/workflows/dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ jobs:
files: build/distributions/org.lwdita-*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to registry
uses: ./.github/actions/registry
with:
TOKEN: ${{ secrets.TOKEN }}
FORK: jelovirt/registry
CHKSUM: ${{ env.CHKSUM }}
VERSION: ${{ env.VERSION }}
PLUGIN_NAME: org.lwdita
URL: https://github.com/jelovirt/org.lwdita/releases/download/${{ env.VERSION }}/org.lwdita-${{ env.VERSION }}.zip
- name: Publish package
run: ./gradlew publish
env:
Expand All @@ -36,35 +45,3 @@ jobs:
run: |
echo "CHKSUM=$(shasum -a 256 build/distributions/org.lwdita-*.zip | cut -d ' ' -f 1)" >> $GITHUB_ENV
echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_ENV
echo "PLUGIN_NAME=org.lwdita" >> $GITHUB_ENV
- name: Check out registry
uses: actions/checkout@v3
with:
repository: dita-ot/registry
path: registry
- name: Update registry
working-directory: registry
run: |
URL=https://github.com/jelovirt/org.lwdita/releases/download/${{ env.VERSION }}/org.lwdita-${{ env.VERSION }}.zip
cat ${{ env.PLUGIN_NAME }}.json \
| jq '.[length -1]' \
| jq --arg url "$URL" '. | .url|=$url' \
| jq --arg chksum "${{ env.CHKSUM }}" '. | .cksum|=$chksum' \
| jq --arg vers "${{ env.VERSION }}" '. | .vers|=$vers' > buf.json
jq '. += [input]' ${{ env.PLUGIN_NAME }}.json buf.json \
| jq . > concat.json
mv concat.json ${{ env.PLUGIN_NAME }}.json
rm buf.json
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
path: registry
token: ${{ secrets.TOKEN }}
push-to-fork: jelovirt/registry
branch-suffix: timestamp
commit-message: Add ${{ env.PLUGIN_NAME }} ${{ env.VERSION }}
title: Add ${{ env.PLUGIN_NAME }} ${{ env.VERSION }}
body: |
Add plug-in `${{ env.PLUGIN_NAME }}` version `${{ env.VERSION }}`.

* [Release notes](https://github.com/jelovirt/org.lwdita/releases/tag/${{ env.VERSION }})