From ea95c441c66e0582056ab334895376e60ed09f22 Mon Sep 17 00:00:00 2001 From: Daniel Genis Date: Tue, 31 Oct 2023 11:31:45 +0100 Subject: [PATCH] ci: fix publishing --- .github/jsonnet/GIT_VERSION | 2 +- .github/jsonnet/complete-workflows.jsonnet | 4 ++-- .github/jsonnet/deployment.jsonnet | 4 ++-- .github/jsonnet/misc.jsonnet | 14 ++++++++------ .github/jsonnet/yarn.jsonnet | 10 +++++++--- .github/workflows/pr.yml | 2 +- .github/workflows/publish-prod.yml | 4 ++-- package.json | 2 +- 8 files changed, 24 insertions(+), 18 deletions(-) diff --git a/.github/jsonnet/GIT_VERSION b/.github/jsonnet/GIT_VERSION index f11077c..33a0530 100644 --- a/.github/jsonnet/GIT_VERSION +++ b/.github/jsonnet/GIT_VERSION @@ -1 +1 @@ -9f0090f332fe3306ec145c60d2e129628aee2f9c +afbecf4e8ac7ba526d30b74f71f29f0f287074b1 diff --git a/.github/jsonnet/complete-workflows.jsonnet b/.github/jsonnet/complete-workflows.jsonnet index b4735fe..49a089b 100644 --- a/.github/jsonnet/complete-workflows.jsonnet +++ b/.github/jsonnet/complete-workflows.jsonnet @@ -15,9 +15,9 @@ $.pipeline( 'publish-prod', [ - $.yarnPublishJob(repositories, runsOn=runsOn), + $.yarnPublishJob(repositories=repositories, runsOn=runsOn), ], - event={ push: { branches: ['${{ github.event.pull_request.base.ref }}'] } }, + event={ push: { branches: ['${{ github.event.pull_request.base.repo.default_branch }}'] } }, ) + $.pipeline( 'pr', diff --git a/.github/jsonnet/deployment.jsonnet b/.github/jsonnet/deployment.jsonnet index 057abde..a9d7158 100644 --- a/.github/jsonnet/deployment.jsonnet +++ b/.github/jsonnet/deployment.jsonnet @@ -45,7 +45,7 @@ 'auto-merge': 'false', ref: '${{ github.event.pull_request.head.sha }}', description: 'Auto deploy production on PR merge. pr: ${{ github.event.number }} ref: ${{ github.event.pull_request.head.sha }}', - payload: '{ "pr" : ${{ github.event.number }}, "branch": "${{ github.head_ref }}" }', + payload: '{ "pr" : ${{ github.event.number }}, "branch": "${{ github.head_ref }}", "base_ref": "${{ github.event.pull_request.base.sha }}", "head_ref": "${{ github.event.pull_request.head.sha }}" }', } ), $.sendSlackMessage( @@ -74,7 +74,7 @@ 'auto-merge': 'false', ref: '${{ github.event.pull_request.head.sha }}', description: 'Auto deploy test on PR merge. pr: ${{ github.event.number }} ref: ${{ github.event.pull_request.head.sha }}', - payload: '{ "pr" : ${{ github.event.number }}, "branch": "${{ github.head_ref }}" }', + payload: '{ "pr" : ${{ github.event.number }}, "branch": "${{ github.head_ref }}", "base_ref": "${{ github.event.pull_request.base.sha }}", "head_ref": "${{ github.event.pull_request.head.sha }}" }', } ), ], diff --git a/.github/jsonnet/misc.jsonnet b/.github/jsonnet/misc.jsonnet index 65372fa..5d97734 100644 --- a/.github/jsonnet/misc.jsonnet +++ b/.github/jsonnet/misc.jsonnet @@ -201,7 +201,7 @@ // if: steps.changes.outputs.app == 'true' // // See https://github.com/dorny/paths-filter for more information. - testForChangedFiles(changedFiles):: + testForChangedFiles(changedFiles, headRef=null, baseRef=null):: [ $.step('git safe directory', 'git config --global --add safe.directory $PWD'), $.action( @@ -209,11 +209,13 @@ uses='dorny/paths-filter@v2', id='changes', with={ - filters: ||| - %s - ||| % std.manifestYamlDoc(changedFiles), - token: '${{ github.token }}', - } + filters: ||| + %s + ||| % std.manifestYamlDoc(changedFiles), + token: '${{ github.token }}', + } + + (if headRef != null then { ref: headRef } else {}) + + (if baseRef != null then { base: baseRef } else {}), ), ], diff --git a/.github/jsonnet/yarn.jsonnet b/.github/jsonnet/yarn.jsonnet index 172541d..624f737 100644 --- a/.github/jsonnet/yarn.jsonnet +++ b/.github/jsonnet/yarn.jsonnet @@ -156,7 +156,7 @@ echo "Setting tag/version for release/tag build."; PUBLISHVERSION=$VERSION; TAG="latest"; - elif [[ "${GITHUB_REF_TYPE}" == "branch" && "${GITHUB_REF_NAME}" == "main" ]]; then + elif [[ "${GITHUB_REF_TYPE}" == "branch" && "${GITHUB_REF_NAME}" == "main" ]] || [[ "${GITHUB_EVENT_NAME}" == "deployment" ]]; then echo "Setting tag/version for release/tag build."; PUBLISHVERSION=$VERSION; TAG="latest"; @@ -189,6 +189,8 @@ checkVersionBump=true, repositories=['gynzy'], onChangedFiles=false, + changedFilesHeadRef=null, + changedFilesBaseRef=null, runsOn=null, ): local ifClause = (if onChangedFiles != false then "steps.changes.outputs.package == 'true'" else null); @@ -199,7 +201,7 @@ useCredentials=false, steps= [$.checkoutAndYarn(ref=gitCloneRef, fullClone=false)] + - (if onChangedFiles != false then $.testForChangedFiles({ package: onChangedFiles }) else []) + + (if onChangedFiles != false then $.testForChangedFiles({ package: onChangedFiles }, headRef=changedFilesHeadRef, baseRef=changedFilesBaseRef) else []) + (if checkVersionBump then [ $.action('check-version-bump', uses='del-systems/check-if-version-bumped@v1', with={ token: '${{ github.token }}', @@ -217,6 +219,8 @@ buildSteps=[$.step('build', 'yarn build')], repositories=['gynzy'], onChangedFiles=false, + changedFilesHeadRef=null, + changedFilesBaseRef=null, ifClause=null, runsOn=null, ): @@ -228,7 +232,7 @@ useCredentials=false, steps= [$.checkoutAndYarn(ref=gitCloneRef, fullClone=false)] + - (if onChangedFiles != false then $.testForChangedFiles({ package: onChangedFiles }) else []) + + (if onChangedFiles != false then $.testForChangedFiles({ package: onChangedFiles }, headRef=changedFilesHeadRef, baseRef=changedFilesBaseRef) else []) + (if onChangedFiles != false then std.map(function(step) std.map(function(s) s { 'if': stepIfClause }, step), buildSteps) else buildSteps) + $.yarnPublishToRepositories(isPr=false, repositories=repositories, ifClause=stepIfClause), permissions={ packages: 'write', contents: 'read', 'pull-requests': 'read' }, diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index de5713b..394efe0 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -88,7 +88,7 @@ echo "Setting tag/version for release/tag build."; PUBLISHVERSION=$VERSION; TAG="latest"; - elif [[ "${GITHUB_REF_TYPE}" == "branch" && "${GITHUB_REF_NAME}" == "main" ]]; then + elif [[ "${GITHUB_REF_TYPE}" == "branch" && "${GITHUB_REF_NAME}" == "main" ]] || [[ "${GITHUB_EVENT_NAME}" == "deployment" ]]; then echo "Setting tag/version for release/tag build."; PUBLISHVERSION=$VERSION; TAG="latest"; diff --git a/.github/workflows/publish-prod.yml b/.github/workflows/publish-prod.yml index 95bfec5..edef13b 100644 --- a/.github/workflows/publish-prod.yml +++ b/.github/workflows/publish-prod.yml @@ -54,7 +54,7 @@ echo "Setting tag/version for release/tag build."; PUBLISHVERSION=$VERSION; TAG="latest"; - elif [[ "${GITHUB_REF_TYPE}" == "branch" && "${GITHUB_REF_NAME}" == "main" ]]; then + elif [[ "${GITHUB_REF_TYPE}" == "branch" && "${GITHUB_REF_NAME}" == "main" ]] || [[ "${GITHUB_EVENT_NAME}" == "deployment" ]]; then echo "Setting tag/version for release/tag build."; PUBLISHVERSION=$VERSION; TAG="latest"; @@ -71,4 +71,4 @@ "on": "push": "branches": - - "${{ github.event.pull_request.base.ref }}" \ No newline at end of file + - "${{ github.event.pull_request.base.repo.default_branch }}" \ No newline at end of file diff --git a/package.json b/package.json index 903860a..99ef562 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gynzy/ember-redux", - "version": "6.0.3", + "version": "6.0.4", "description": "ember-cli addon that provides simple redux bindings for ember.js", "scripts": { "build": "ember build",