-
Notifications
You must be signed in to change notification settings - Fork 10
Introduce pre-prod for rel-scripts [DI-718]
#61
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
Changes from all commits
ce4eff0
0875dc3
b08c8e0
8224a7f
f23b44a
a05f81c
947391a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # To ensure that both setter and getter use the same format | ||
| name: Get Hazelcast Platform PR Title | ||
|
|
||
| inputs: | ||
| hz-version: | ||
| required: true | ||
| outputs: | ||
| title: | ||
| value: Hazelcast platform release ${{ inputs.hz-version }} | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - shell: bash | ||
| run: exit 0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| name: Package Hazelcast platform release metadata | ||
| description: Creates a draft PR for the updated release metadata, after adding the required Hazelcast platform release | ||
| run-name: ${{ github.workflow }} (`${{ inputs.VERSION }}`@${{ inputs.ENVIRONMENT }}) | ||
|
|
||
| on: | ||
| # Called from release pipeline | ||
| workflow_dispatch: | ||
| inputs: | ||
| VERSION: | ||
| description: 'The version to release (e.g. `5.4.1`)' | ||
| required: true | ||
| RELEASE_TYPE: | ||
| description: 'What should be built' | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - ALL | ||
| - OSS | ||
| - EE | ||
| ENVIRONMENT: | ||
| description: 'Environment to use' | ||
| required: true | ||
| type: environment | ||
|
|
||
| jobs: | ||
| package: | ||
| environment: | ||
| name: ${{ inputs.ENVIRONMENT }} | ||
| deployment: false | ||
| runs-on: ubuntu-slim | ||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
| pull-requests: write | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| # Required to get the default branch as well, to allow `gh` to accurately determine the diff between branches when deriving PR title from commits | ||
|
nishaatr marked this conversation as resolved.
|
||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - id: resolve-editions | ||
| uses: hazelcast/docker-actions/resolve-editions@master | ||
| with: | ||
| release-type: ${{ inputs.RELEASE_TYPE }} | ||
|
|
||
| - uses: hazelcast/docker-actions/get-jfrog-credentials@master | ||
| # Other environments use public artifacts, where credentials aren't required | ||
|
nishaatr marked this conversation as resolved.
|
||
| if: inputs.ENVIRONMENT == 'sandbox' | ||
| id: jfrog | ||
| with: | ||
| aws-role-to-assume: ${{ vars.AWS_HAZELCAST_OIDC_GITHUB_ACTIONS_ROLE_ARN }} | ||
| jfrog-oidc-provider-name: ${{ github.repository_owner }}-snapshot-internal | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| pip3 install -r .github/python/add-release/requirements.txt | ||
|
|
||
| - name: Update metadata | ||
| run: | | ||
| python3 .github/python/add-release/add_release.py \ | ||
| --version=${VERSION} \ | ||
| --github-org=${GITHUB_REPOSITORY_OWNER} \ | ||
| --ee-release-repo-name=${{ vars.EE_RELEASE_REPO_NAME }} \ | ||
| --should-build-oss=${{ steps.resolve-editions.outputs.should_build_oss }} \ | ||
| --should-build-ee=${{ steps.resolve-editions.outputs.should_build_ee }} | ||
| env: | ||
| VERSION: ${{ inputs.VERSION }} | ||
| RELEASE_REPO_USER: ${{ steps.jfrog.outputs.user }} | ||
| RELEASE_REPO_TOKEN: ${{ steps.jfrog.outputs.token }} | ||
|
|
||
| - uses: ./.github/actions/get-hazelcast-platform-pr-title | ||
| id: get-pr-title | ||
| with: | ||
| hz-version: ${{ inputs.VERSION }} | ||
|
|
||
| - name: Create PR for changes | ||
|
ldziedziul marked this conversation as resolved.
|
||
| run: | | ||
| git config --global user.name "${GITHUB_ACTOR}" | ||
| git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
|
|
||
| # Make a new branch from the default one | ||
| # The default branch is the ultimate target of the PR, not the current one | ||
| # For _typical_ workflow execution this is the same | ||
| # But when testing changes, if running from the non-default branch (e.g. a branch with your workflow changes), the resultant version update PR will _also_ include those changes | ||
| git checkout \ | ||
| -b "${{ github.job }}_run_${{ github.run_id }}" \ | ||
|
nishaatr marked this conversation as resolved.
|
||
| ${{ github.event.repository.default_branch }} | ||
|
|
||
| git commit \ | ||
| --all \ | ||
| --message="${{ steps.get-pr-title.outputs.title }}" \ | ||
| --message="Generated by ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}." | ||
| git push -u origin HEAD | ||
|
|
||
| gh pr create \ | ||
| --assignee "${GITHUB_ACTOR}" \ | ||
| --fill \ | ||
| --draft | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,80 +1,110 @@ | ||
| name: Add Hazelcast platform release | ||
| run-name: ${{ github.workflow }} (`${{ inputs.VERSION }}`@${{ inputs.ENVIRONMENT }}) | ||
| name: Promote Hazelcast platform release metadata | ||
| description: Identifies the corresponding PR for the updated release metadata from `package.yml`, updating as required and merging | ||
| run-name: ${{ github.workflow }} (`${{ inputs.VERSION }}`) | ||
|
|
||
| on: | ||
| # Called from release orchestrator | ||
| workflow_dispatch: | ||
| inputs: | ||
| VERSION: | ||
| description: 'The version to release (e.g. `5.4.1`)' | ||
| description: 'The version to promote (e.g. `5.4.1`)' | ||
| required: true | ||
| RELEASE_TYPE: | ||
| description: 'What should be built' | ||
| required: true | ||
| description: 'Unused, provided for compatibility with a common release promotion interface' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the plan for these redundant inputs?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have one - this is the first time it's come up. I don't think think it's terrible this way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a task to backlog to not forget about it
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Task for what? Not sure what the solution would be, if any. |
||
| required: false | ||
| type: choice | ||
| options: | ||
| - ALL | ||
| - OSS | ||
| - EE | ||
| ENVIRONMENT: | ||
| description: 'Environment to use' | ||
| required: true | ||
| description: 'Unused, provided for compatibility with a common release promotion interface' | ||
| required: false | ||
| type: environment | ||
| distinct_id: | ||
| description: 'Required exclusively for automated execution to track status of workflow execution' | ||
| required: false | ||
|
|
||
| jobs: | ||
| add-release: | ||
| environment: ${{ inputs.ENVIRONMENT }} | ||
| promote: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| env: | ||
| VERSION: ${{ inputs.VERSION }} | ||
| pull-requests: write | ||
| steps: | ||
| # https://github.com/Codex-/return-dispatch#receiving-repository-action | ||
| - name: Logging distinct ID (${{ inputs.distinct_id }}) | ||
| run: echo "${DISTINCT_ID}" | ||
| env: | ||
| DISTINCT_ID: ${{ inputs.distinct_id }} | ||
|
|
||
| - uses: actions/checkout@v6 | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - id: resolve-editions | ||
| uses: hazelcast/docker-actions/resolve-editions@master | ||
| - uses: ./.github/actions/get-hazelcast-platform-pr-title | ||
| id: get-pr-title | ||
| with: | ||
| release-type: ${{ inputs.RELEASE_TYPE }} | ||
| hz-version: ${{ inputs.VERSION }} | ||
|
|
||
| - name: Find corresponding staged PR | ||
| id: find-pr | ||
| run: | | ||
| set -o errexit -o nounset -o pipefail ${RUNNER_DEBUG:+-x} | ||
|
|
||
| source /dev/stdin <<< "$(curl --silent https://raw.githubusercontent.com/hazelcast/github-actions-common-scripts/main/logging.functions.sh)" | ||
|
|
||
| PR_JSON=$(gh pr list \ | ||
| --search "'${{ steps.get-pr-title.outputs.title }}' in:title author:app/github-actions" \ | ||
| --json number,headRefName \ | ||
| --jq '.[0]') | ||
|
nishaatr marked this conversation as resolved.
|
||
|
|
||
| echodebug "PR search result - ${PR_JSON}" | ||
|
|
||
| PR_NUMBER=$(jq -r .number <<< "${PR_JSON}") | ||
| PR_BRANCH=$(jq -r .headRefName <<< "${PR_JSON}") | ||
|
|
||
| - uses: hazelcast/docker-actions/get-jfrog-credentials@master | ||
| if: inputs.ENVIRONMENT == 'sandbox' | ||
| id: jfrog | ||
| echo "Found PR = #${PR_NUMBER}, branch = ${PR_BRANCH}" | ||
|
|
||
| if [[ -n "${PR_NUMBER}" || -n "${PR_BRANCH}" ]]; then | ||
| echo "PR_NUMBER=${PR_NUMBER}" >> ${GITHUB_OUTPUT} | ||
|
JackPGreen marked this conversation as resolved.
|
||
| echo "PR_BRANCH=${PR_BRANCH}" >> ${GITHUB_OUTPUT} | ||
| else | ||
| echoerr "No matching PR found to promote" | ||
| exit 1 | ||
| fi | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
|
|
||
| - name: 'Checkout PR #${{ steps.find-pr.outputs.PR_NUMBER }} (`${{ steps.find-pr.outputs.PR_BRANCH }}`)' | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| aws-role-to-assume: ${{ vars.AWS_HAZELCAST_OIDC_GITHUB_ACTIONS_ROLE_ARN }} | ||
| jfrog-oidc-provider-name: ${{ github.repository_owner }}-snapshot-internal | ||
| ref: ${{ steps.find-pr.outputs.PR_BRANCH }} | ||
|
|
||
| - name: Install dependencies | ||
| - name: Update release date in files | ||
| run: | | ||
| pip3 install -r .github/python/add-release/requirements.txt | ||
| export TBC_RELEASE_DATE=$(date +%m/%d/%Y) | ||
| echo "Updating TBC_RELEASE_DATE -> ${TBC_RELEASE_DATE}..." | ||
|
|
||
| - name: Update metadata | ||
| run: | | ||
| python3 .github/python/add-release/add_release.py \ | ||
| --version=${VERSION} \ | ||
| --github-org=${GITHUB_REPOSITORY_OWNER} \ | ||
| --ee-release-repo-name=${{ vars.EE_RELEASE_REPO_NAME }} \ | ||
| --should-build-oss=${{ steps.resolve-editions.outputs.should_build_oss }} \ | ||
| --should-build-ee=${{ steps.resolve-editions.outputs.should_build_ee }} | ||
| env: | ||
| RELEASE_REPO_USER: ${{ steps.jfrog.outputs.user }} | ||
| RELEASE_REPO_TOKEN: ${{ steps.jfrog.outputs.token }} | ||
| find . -type f -name "*.txt" -print0 | while IFS= read -r -d '' file; do | ||
| envsubst '$TBC_RELEASE_DATE' < "${file}" > "${file}.tmp" && mv "${file}.tmp" "${file}" | ||
|
JackPGreen marked this conversation as resolved.
|
||
| done | ||
|
|
||
| - name: Push back changes | ||
| - name: 'Commit changes to PR #${{ steps.find-pr.outputs.PR_NUMBER }}' | ||
| run: | | ||
| git config --global user.name "${GITHUB_ACTOR}" | ||
| git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
|
|
||
| git commit --all \ | ||
| --message="Hazelcast platform release ${VERSION}" \ | ||
|
|
||
| git commit \ | ||
| --all \ | ||
| --message="Updating release date" \ | ||
| --message="Generated by ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}." | ||
| git push | ||
|
|
||
| - name: 'Merge PR #${{ steps.find-pr.outputs.PR_NUMBER }}' | ||
| run: | | ||
| gh pr ready | ||
|
|
||
| gh pr merge \ | ||
| --squash | ||
|
nishaatr marked this conversation as resolved.
|
||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add move logging:
and use step output as action output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will already be able to see that output in the debug logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but then I need to re-run or check consumer of this steps. I think it makes debugging easier when action print basic information by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some more logging - 8224a7f
You can see the output of that command in the regular logs already:
If the information is already there I would rather leave as is than duplicately log incase they diverge.