Skip to content

Commit

Permalink
initial structure
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinBettati committed Apr 16, 2024
1 parent 6c7e1d5 commit 5bc5dba
Showing 1 changed file with 66 additions and 37 deletions.
103 changes: 66 additions & 37 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,33 @@ on:

jobs:

setup:
runs-on: ubuntu-latest
outputs:
creates_new_tag: ${{ steps.condition_check.outputs.creates_new_tag }}
is_official_release: ${{ steps.condition_check.outputs.is_official_release }}
runs_tests: ${{ steps.condition_check.outputs.runs_tests }}
steps:
- id: condition_check
run: |
echo "creates_new_tag=$(if [ '${{ inputs.use_existing_tag }}' = 'true' ]; then echo 'false'; else echo 'true'; fi)" >> $GITHUB_ENV
echo "is_official_release=$(if echo '${{ inputs.version_number }}' | grep -q 'pre'; then echo 'false'; else echo 'true'; fi)" >> $GITHUB_ENV
echo "runs_tests=$(if [ '${{ inputs.skip_tests }}' = 'true' ]; then echo 'false'; else echo 'true'; fi)" >> $GITHUB_ENV
validate-version-input:
runs-on: ubuntu-latest
steps:
- name: Validation of version format
run: |
echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+(-pre[A-Za-z0-9-]*)?$'
echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+(-pre[A-Za-z0-9-]*)?$'
run-qa-acceptance-tests:
needs: [ validate-version-input ]
# QA acceptance tests are skipped when explicit input parameter is used
# As this job may be skipped following jobs require using 'always()' to make sure they are still run
if: needs.validate-version-input.result == 'success' && inputs.skip_tests != 'true'
secrets: inherit
uses: ./.github/workflows/acceptance-tests.yml
with:
atlas_cloud_env: "qa"
ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || github.ref }}

update-examples-reference-in-docs:
needs: [ validate-version-input, run-qa-acceptance-tests ]
needs: [ setup, validate-version-input ]
if: >-
always()
&& inputs.use_existing_tag != 'true'
&& !contains(inputs.version_number, 'pre')
&& needs.validate-version-input.result == 'success'
&& (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success')
&& needs.setup.outputs.creates_new_tag
&& needs.setup.outputs.is_official_release
&& needs.validate-version-input.result == 'success'
uses: ./.github/workflows/run-script-and-commit.yml
with:
script_call: './scripts/update-examples-reference-in-docs.sh ${{inputs.version_number}}'
Expand All @@ -50,38 +51,32 @@ jobs:
user_name: 'releasebot'

update-changelog-header:
needs: [ validate-version-input, run-qa-acceptance-tests, update-examples-reference-in-docs ]
needs: [ setup, validate-version-input, update-examples-reference-in-docs ]
if: >-
always()
&& inputs.use_existing_tag != 'true'
&& !contains(inputs.version_number, 'pre')
&& needs.validate-version-input.result == 'success'
&& (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success')
&& needs.setup.outputs.creates_new_tag
&& needs.setup.outputs.is_official_release
&& needs.validate-version-input.result == 'success'
uses: ./.github/workflows/run-script-and-commit.yml
with:
script_call: './scripts/update-changelog-header-for-release.sh ${{inputs.version_number}}'
file_to_commit: 'CHANGELOG.md'
commit_message: 'Update CHANGELOG.md header for ${{ github.event.inputs.version_number }} release'
user_email: '[email protected]'
user_name: 'releasebot'
release:

create-tag:
runs-on: ubuntu-latest
needs: [ validate-version-input, run-qa-acceptance-tests, update-examples-reference-in-docs, update-changelog-header ]
# Release is skipped if there are failures in previous steps
if: >-
needs: [ setup, validate-version-input, update-examples-reference-in-docs, update-changelog-header ]
if: >-
always()
&& needs.validate-version-input.result == 'success'
&& (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success')
&& needs.setup.outputs.creates_new_tag
&& needs.validate-version-input.result == 'success'
&& (needs.update-examples-reference-in-docs.result == 'skipped' || needs.update-examples-reference-in-docs.result == 'success')
&& (needs.update-changelog-header.result == 'skipped' || needs.update-changelog-header.result == 'success')
steps:
steps:
- name: Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || 'master' }}
- name: Unshallow
run: git fetch --prune --unshallow
- name: Get the latest commit SHA
id: get-sha
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
Expand All @@ -92,7 +87,38 @@ jobs:
commit_sha: ${{ steps.get-sha.outputs.sha }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.PASSPHRASE }}
tag_exists_error: ${{ inputs.use_existing_tag != 'true' }}

run-qa-acceptance-tests:
needs: [ setup, validate-version-input, update-examples-reference-in-docs, update-changelog-header, create-tag ]
if: >-
always()
&& needs.setup.outputs.runs_tests
&& needs.validate-version-input.result == 'success'
&& (needs.update-examples-reference-in-docs.result == 'skipped' || needs.update-examples-reference-in-docs.result == 'success')
&& (needs.update-changelog-header.result == 'skipped' || needs.update-changelog-header.result == 'success')
&& (needs.create-tag.result == 'skipped' || needs.create-tag.result == 'success')
secrets: inherit
uses: ./.github/workflows/acceptance-tests.yml
with:
atlas_cloud_env: "qa"
ref: ${{ inputs.version_number }}

release:
runs-on: ubuntu-latest
needs: [ validate-version-input, update-examples-reference-in-docs, update-changelog-header, create-tag, run-qa-acceptance-tests ]
# Release is skipped if there are failures in previous steps
if: >-
always()
&& needs.validate-version-input.result == 'success'
&& (needs.update-examples-reference-in-docs.result == 'skipped' || needs.update-examples-reference-in-docs.result == 'success')
&& (needs.update-changelog-header.result == 'skipped' || needs.update-changelog-header.result == 'success')
&& (needs.create-tag.result == 'skipped' || needs.create-tag.result == 'success')
&& (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success')
steps:
- name: Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
ref: ${{ inputs.version_number }}
- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
Expand All @@ -113,9 +139,12 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jira-release-version:
if: ${{ !contains(inputs.version_number, 'pre') }}
needs: [ release ]
runs-on: ubuntu-latest
needs: [ setup, release ]
if: >-
always()
&& needs.setup.outputs.is_official_release
&& needs.release.result == 'success'
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
Expand Down

0 comments on commit 5bc5dba

Please sign in to comment.