diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml index 393f1f2b..b2a005ff 100644 --- a/.github/workflows/check-pr.yml +++ b/.github/workflows/check-pr.yml @@ -8,6 +8,7 @@ on: - opened - reopened - ready_for_review + - synchronize jobs: get_versions: @@ -32,5 +33,7 @@ jobs: version: ${{ matrix.version }} push_changed: false publish: false - - \ No newline at end of file + # Publishing of PRs will only work correctly if we're only building a single one + # NOTE: There is no way to get the length of an array in Github Actions Expressions + # So the heuristic is: If it contains a comma, it's a list with more than one element. + publish_prs: ${{ !contains(needs.get_versions.outputs.versions, ',') }} diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 7cbb5d26..bb70266e 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -21,6 +21,10 @@ on: default: true required: false type: boolean + publish_prs: + default: false + required: false + type: boolean secrets: MAVEN_USER: required: false @@ -118,6 +122,13 @@ jobs: with: name: neoform-${{ fromJson(steps.split_version.outputs.result).version_name }} path: build/distributions/*.zip + # This creates a "maven-publish" artifact that contains the results of a locally run publish task + # This artifact is picked up by the "publish-prs.yml" workflow for PRs and published to a temporary maven repository + - name: Publish artifacts for PR Publication + uses: neoforged/action-pr-publishing/upload@v1 + if: ${{ inputs.publish_prs }} + with: + publishing-task: ":${{ fromJson(steps.split_version.outputs.result).version_name }}:publishAllPublicationsTo_githubPackages_PRsRepository -Ptype=${{ fromJson(steps.split_version.outputs.result).version_type }}" - name: Get Java Test Versions id: test_versions env: diff --git a/.github/workflows/publish-prs.yml b/.github/workflows/publish-prs.yml new file mode 100644 index 00000000..214fd9aa --- /dev/null +++ b/.github/workflows/publish-prs.yml @@ -0,0 +1,30 @@ +# File generated by the GradleUtils `setupGitHubActionsWorkflows` task, avoid modifying it directly +# The template can be found at https://github.com/neoforged/GradleUtils/blob/a65628b0c89dec60b357ce3f8f6bfa62934b8357/src/actionsTemplate/resources/.github/workflows/publish-prs.yml + +name: Publish PRs to GitHub Packages + +on: + workflow_run: + workflows: [Check PRs] + types: + - completed + issue_comment: + types: + - edited + pull_request_target: + types: + - opened + +permissions: + packages: write + +jobs: + publish-prs: + if: true + uses: neoforged/actions/.github/workflows/publish-prs.yml@main + with: + artifact_base_path: net/neoforged/neoform/ + uploader-workflow-name: "Check PRs" + secrets: + PR_PUBLISHING_GH_APP_ID: ${{ secrets.PR_PUBLISHING_GH_APP_ID }} + PR_PUBLISHING_GH_APP_KEY: ${{ secrets.PR_PUBLISHING_GH_APP_KEY }}