From 0cb29123e632e6b1afe6232f527821b1cf8b9457 Mon Sep 17 00:00:00 2001 From: Jarno Elovirta Date: Sun, 14 May 2023 15:12:42 +0300 Subject: [PATCH] Split registry publish to composite action Signed-off-by: Jarno Elovirta --- .github/actions/registry/action.yml | 57 +++++++++++++++++++++++++++++ .github/workflows/dist.yml | 41 +++++---------------- 2 files changed, 66 insertions(+), 32 deletions(-) create mode 100644 .github/actions/registry/action.yml diff --git a/.github/actions/registry/action.yml b/.github/actions/registry/action.yml new file mode 100644 index 0000000..0a94170 --- /dev/null +++ b/.github/actions/registry/action.yml @@ -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 }}) diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index acdf1c8..39bf5c9 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -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: @@ -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 }}) \ No newline at end of file