Release-3: PR for merging master into dev #203
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Release-3: PR for merging master into dev" | |
| env: | |
| GIT_USERNAME: "DefectDojo release bot" | |
| GIT_EMAIL: "dojo-release-bot@users.noreply.github.com" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| # the actual branch that can be chosen on the UI is made irrelevant by further steps | |
| # because someone will forget one day to change it. | |
| release_number_new: | |
| description: "Newly just released version (x.y.z format)" | |
| required: true | |
| release_number_dev: | |
| description: "Future release version for dev branch (x.y.z-dev format)" | |
| required: true | |
| jobs: | |
| create_pr_for_merge_back_into_dev: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - id: Set-GitHub-org | |
| run: echo "GITHUB_ORG=${GITHUB_REPOSITORY%%/*}" >> $GITHUB_ENV | |
| - name: Checkout master | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| with: | |
| ref: master | |
| - name: Create merge back branch | |
| run: | | |
| echo "NEW_BRANCH=master-into-dev/${{ inputs.release_number_new }}-${{ inputs.release_number_dev }}" >> $GITHUB_ENV | |
| - name: Configure git | |
| run: | | |
| git config --global user.name "${{ env.GIT_USERNAME }}" | |
| git config --global user.email "${{ env.GIT_EMAIL }}" | |
| - name: Push new branch | |
| run: git push origin HEAD:${NEW_BRANCH} | |
| - name: Checkout new branch | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| with: | |
| ref: ${{ env.NEW_BRANCH }} | |
| - name: Update version numbers in key files | |
| run: | | |
| sed -ri 's/__version__ = ".*"/__version__ = "${{ inputs.release_number_dev }}"/' dojo/__init__.py | |
| sed -ri 's/"version": ".*"/"version": "${{ inputs.release_number_dev }}"/' components/package.json | |
| sed -ri 's/appVersion: ".*"/appVersion: "${{ inputs.release_number_dev }}"/' helm/defectdojo/Chart.yaml | |
| CURRENT_CHART_VERSION=$(grep -oP 'version: (\K\S*)?' helm/defectdojo/Chart.yaml | head -1) | |
| sed -ri "0,/version/s/version: \S+/$(echo "version: $CURRENT_CHART_VERSION" | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{$NF=sprintf("%0*d", length($NF), ($NF+1)); print}')-dev/" helm/defectdojo/Chart.yaml | |
| - name: Check numbers | |
| run: | | |
| grep version dojo/__init__.py | |
| grep appVersion helm/defectdojo/Chart.yaml | |
| grep version components/package.json | |
| - name: Create upgrade notes to documentation | |
| run: | | |
| minorv=$(echo ${{ inputs.release_number_dev }} | cut -d '.' -f -2) | |
| patchv=$(echo ${{ inputs.release_number_dev }} | cut -d '-' -f -1) | |
| weight=$(date +%Y%m%d) | |
| echo -n "--- | |
| title: 'Upgrading to DefectDojo Version $minorv.x' | |
| toc_hide: true | |
| weight: -$weight | |
| description: No special instructions. | |
| --- | |
| There are no special instructions for upgrading to $minorv.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/$patchv) for the contents of the release. | |
| " > docs/content/en/open_source/upgrading/$minorv.md | |
| git add docs/content/en/open_source/upgrading/$minorv.md | |
| if: endsWith(inputs.release_number_new, '.0') && endsWith(inputs.release_number_dev, '.0-dev') | |
| - name: Update values in HELM chart | |
| run: | | |
| yq -i '.annotations = {}' helm/defectdojo/Chart.yaml | |
| yq -i '.annotations."artifacthub.io/prerelease" = "true"' helm/defectdojo/Chart.yaml | |
| yq -i '.annotations."artifacthub.io/changes" = ""' helm/defectdojo/Chart.yaml | |
| - name: Run helm-docs | |
| uses: losisin/helm-docs-github-action@a57fae5676e4c55a228ea654a1bcaec8dd3cf5b5 # v1.6.2 | |
| with: | |
| chart-search-root: "helm/defectdojo" | |
| - name: Push version changes | |
| uses: stefanzweifel/git-auto-commit-action@28e16e81777b558cc906c8750092100bbb34c5e3 # v7.0.0 | |
| with: | |
| commit_user_name: "${{ env.GIT_USERNAME }}" | |
| commit_user_email: "${{ env.GIT_EMAIL }}" | |
| commit_author: "${{ env.GIT_USERNAME }} <${{ env.GIT_EMAIL }}>" | |
| commit_message: "Update versions in application files" | |
| branch: ${{ env.NEW_BRANCH }} | |
| - name: Create Pull Request | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| github.rest.pulls.create({ | |
| owner: '${{ env.GITHUB_ORG }}', | |
| repo: 'django-DefectDojo', | |
| title: 'Release: Merge back ${{ inputs.release_number_new }} into dev from: ${{ env.NEW_BRANCH }}', | |
| body: `Release triggered by \`${ process.env.GITHUB_ACTOR }\``, | |
| head: '${{ env.NEW_BRANCH }}', | |
| base: 'dev' | |
| }) | |
| create_pr_for_merge_back_into_bugfix: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - id: Set-GitHub-org | |
| run: echo "GITHUB_ORG=${GITHUB_REPOSITORY%%/*}" >> $GITHUB_ENV | |
| - name: Checkout master | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| with: | |
| ref: master | |
| - name: Create merge back branch | |
| run: | | |
| echo "NEW_BRANCH=master-into-bugfix/${{ inputs.release_number_new }}-${{ inputs.release_number_dev }}" >> $GITHUB_ENV | |
| - name: Configure git | |
| run: | | |
| git config --global user.name "${{ env.GIT_USERNAME }}" | |
| git config --global user.email "${{ env.GIT_EMAIL }}" | |
| - name: Push new branch | |
| run: git push origin HEAD:${NEW_BRANCH} | |
| - name: Checkout new branch | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| with: | |
| ref: ${{ env.NEW_BRANCH }} | |
| - name: Update version numbers in key files | |
| run: | | |
| sed -ri "s/__version__ = '.*'/__version__ = '${{ inputs.release_number_dev }}'/" dojo/__init__.py | |
| sed -ri "s/appVersion: \".*\"/appVersion: \"${{ inputs.release_number_dev }}\"/" helm/defectdojo/Chart.yaml | |
| sed -ri "s/\"version\": \".*\"/\"version\": \"${{ inputs.release_number_dev }}\"/" components/package.json | |
| CURRENT_CHART_VERSION=$(grep -oP 'version: (\K\S*)?' helm/defectdojo/Chart.yaml | head -1) | |
| sed -ri "0,/version/s/version: \S+/$(echo "version: $CURRENT_CHART_VERSION" | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{$NF=sprintf("%0*d", length($NF), ($NF+1)); print}')-dev/" helm/defectdojo/Chart.yaml | |
| - name: Check numbers | |
| run: | | |
| grep version dojo/__init__.py | |
| grep appVersion helm/defectdojo/Chart.yaml | |
| grep version components/package.json | |
| - name: Update values in HELM chart | |
| run: | | |
| yq -i '.annotations = {}' helm/defectdojo/Chart.yaml | |
| yq -i '.annotations."artifacthub.io/prerelease" = "true"' helm/defectdojo/Chart.yaml | |
| yq -i '.annotations."artifacthub.io/changes" = ""' helm/defectdojo/Chart.yaml | |
| - name: Run helm-docs | |
| uses: losisin/helm-docs-github-action@a57fae5676e4c55a228ea654a1bcaec8dd3cf5b5 # v1.6.2 | |
| with: | |
| chart-search-root: "helm/defectdojo" | |
| - name: Push version changes | |
| uses: stefanzweifel/git-auto-commit-action@28e16e81777b558cc906c8750092100bbb34c5e3 # v7.0.0 | |
| with: | |
| commit_user_name: "${{ env.GIT_USERNAME }}" | |
| commit_user_email: "${{ env.GIT_EMAIL }}" | |
| commit_author: "${{ env.GIT_USERNAME }} <${{ env.GIT_EMAIL }}>" | |
| commit_message: "Update versions in application files" | |
| branch: ${{ env.NEW_BRANCH }} | |
| - name: Create Pull Request | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| github.rest.pulls.create({ | |
| owner: '${{ env.GITHUB_ORG }}', | |
| repo: 'django-DefectDojo', | |
| title: 'Release: Merge back ${{ inputs.release_number_new }} into bugfix from: ${{ env.NEW_BRANCH }}', | |
| body: `Release triggered by \`${ process.env.GITHUB_ACTOR }\``, | |
| head: '${{ env.NEW_BRANCH }}', | |
| base: 'bugfix' | |
| }) |