diff --git a/.github/ISSUE_TEMPLATE/registerAddon.yml b/.github/ISSUE_TEMPLATE/registerAddon.yml new file mode 100644 index 00000000000..9f882e248ef --- /dev/null +++ b/.github/ISSUE_TEMPLATE/registerAddon.yml @@ -0,0 +1,53 @@ +name: Add-on registration +description: Add an NVDA add-on to add-ons datastore +title: "[Submit add-on]: " +labels: [autoSubmissionFromIssue] +assignees: +- nvaccess +body: +# Docs on using issue forms: +# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema +- type: markdown + attributes: + value: | + Submit an NVDA add-on to datastore. Provide download and source URL, and indicate if it's a stable add-on or not. +- type: input + id: download-url + attributes: + label: Download URL + description: The URL to download the add-on. It must start with 'https' and end with 'nvda-addon'. This URL should always download the same file of the same add-on version. + placeholder: https://github.com/userName/addonName/releases/releaseNumber/download/addonName.nvda-addon + validations: + required: true +- type: input + id: source-url + attributes: + label: Source URL + description: The URL to review the source code of the submitted add-on. + placeholder: https://github.com/username/repo/ + validations: + required: true +- type: dropdown + id: channel + attributes: + label: Channel + description: Channel for this add-on release. + multiple: false + options: + - stable + - beta + - dev + validations: + required: true +- type: input + id: license-name + attributes: + label: License Name + description: What license is this add-on released under? + value: GPL v2 +- type: input + id: license-url + attributes: + label: License URL + description: The URL for the license of this add-on + value: https://www.gnu.org/licenses/gpl-2.0.html diff --git a/.github/workflows/getData.js b/.github/workflows/getData.js new file mode 100644 index 00000000000..e43fb896604 --- /dev/null +++ b/.github/workflows/getData.js @@ -0,0 +1,33 @@ +module.exports = ({context, core}) => { + // Allow identifying the issue later. + // setOutput exposes the variable for access at later stages via steps.get-data.outputs + // + const issueTitle = context.payload.issue.title + core.setOutput('issueTitle', issueTitle) + const issueNumber = context.payload.issue.number + core.setOutput('issueNumber', issueNumber) + // Knowing the submitter may be helpful + // const issueSubmitter = context.payload.sender.login + // + // Field headers, Md == Markdown + const header3Prefix = "###" + const dlTitleMd = "### Download URL" + const sourceUrlMd = "### Source URL" + const channelMd = "### Channel" + const licenseMd = "### License Name" + const licenseUrlMd = "### License URL" + // + // collect variables from issue form + // + const body = context.payload.issue.body + const downloadUrl = body.split(dlTitleMd)[1].split(header3Prefix)[0].trim() + core.setOutput('downloadUrl', downloadUrl) + const sourceUrl = body.split(sourceUrlMd)[1].split(header3Prefix)[0].trim() + core.setOutput('sourceUrl', sourceUrl) + const releaseChannel = body.split(channelMd)[1].split(header3Prefix)[0].trim() + core.setOutput('releaseChannel', releaseChannel) + const licenseName = body.split(licenseMd)[1].split(header3Prefix)[0].trim() + core.setOutput('licenseName', licenseName) + const licenseUrl = body.split(licenseUrlMd)[1].split(header3Prefix)[0].trim() + core.setOutput('licenseUrl', licenseUrl) +} diff --git a/.github/workflows/sendJsonFile.yaml b/.github/workflows/sendJsonFile.yaml new file mode 100644 index 00000000000..08feb1e33a1 --- /dev/null +++ b/.github/workflows/sendJsonFile.yaml @@ -0,0 +1,64 @@ +name: Send json file + +on: + issues: + types: + - labeled + +jobs: + check-addon: + name: Check add-on + if: github.event.label.name == 'autoSubmissionFromIssue' + runs-on: windows-latest + steps: + - name: Checkout datastore repo + uses: actions/checkout@v3 + with: + repository: nvdaes/addon-datastore + ref: master + path: datastore + - name: Get data + id: get-data + uses: actions/github-script@v6 + with: + script: | + const setOutputFromIssue = require('./datastore/.github/workflows/getData.js') + setOutputFromIssue({context, core}) + - name: Checkout validate repo + uses: actions/checkout@v3 + with: + repository: nvaccess/addon-datastore-validation + submodules: true + path: validation + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + - name: Download add-on + run: curl --location --output addon.nvda-addon ${{ steps.get-data.outputs.downloadUrl }} + - name: Create JSON submission from issue + run: | + validation\runcreatejson -f addon.nvda-addon --dir datastore\addons --channel=${{ steps.get-data.outputs.releaseChannel }} --publisher=${{ github.event.sender.login }} --sourceUrl=${{ steps.get-data.outputs.sourceUrl }} --url=${{ steps.get-data.outputs.downloadUrl }} --licName="${{ steps.get-data.outputs.licenseName }}" --licUrl=${{ steps.get-data.outputs.licenseURL }} + shell: cmd + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v4 + with: + token: ${{secrets.PR_ACCESS_TOKEN }} + path: datastore + title: ${{ steps.get-data.outputs.issueTitle }} + branch: ${{ github.event.sender.login }}${{ steps.get-data.outputs.issueNumber }} + commit-message: ${{ steps.get-data.outputs.issueTitle }} + body: "Closes issue #${{ steps.get-data.outputs.issueNumber }}" + author: github-actions + - name: Enable Pull Request Automerge + if: steps.cpr.outputs.pull-request-operation == 'created' + uses: peter-evans/enable-pull-request-automerge@v2 + with: + token: ${{ secrets.PR_ACCESS_TOKEN }} + pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} + - name: Close Issue + uses: peter-evans/close-issue@v2 + with: + issue-number: ${{ steps.get-data.outputs.issueNumber }} + comment: Auto-closing issue