Release #107
This file contains 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
# Copyright 2021 EPAM Systems | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
agent: | |
description: 'Agent to release' | |
required: true | |
paths-ignore: | |
- README.md | |
- README_TEMPLATE.md | |
- gradle.properties | |
- CHANGELOG.md | |
env: | |
VERSION_FILE: gradle.properties | |
VERSION_EXTRACT_PATTERN: '(?<=version=).+' | |
REPOSITORY_URL: 'https://maven.pkg.github.com/' | |
CHANGE_LOG_FILE: CHANGELOG.md | |
CHANGE_LOG_TMP_FILE: CHANGELOG_updated.md | |
README_FILE: README.md | |
README_TEMPLATE_FILE: README_TEMPLATE.md | |
README_VERSION_PLACEHOLDER: $LATEST_VERSION | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Generate versions | |
uses: HardNorth/github-version-generate@v1 | |
with: | |
version-source: file | |
version-file: ${{ github.event.inputs.agent }}/${{ env.VERSION_FILE }} | |
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }} | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- name: Setup git credentials | |
uses: oleksiyrudenko/[email protected] | |
with: | |
name: 'reportportal.io' | |
email: '[email protected]' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Release with Gradle | |
id: release | |
run: | | |
./gradlew ${{ github.event.inputs.agent }}:release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${{ env.RELEASE_VERSION }} \ | |
-Prelease.newVersion=${{ env.NEXT_VERSION }} -PpublishRepo=${{ env.REPOSITORY_URL }}${{ github.repository }} \ | |
-PgithubUserName=${{ github.actor }} -PgithubToken=${{ secrets.GITHUB_TOKEN }} \ | |
-PgpgPassphrase=${{ secrets.GPG_PASSPHRASE }} -PgpgPrivateKey="${{ secrets.GPG_PRIVATE_KEY }}" | |
- name: Update README.md | |
id: readmeUpdate | |
run: | | |
sed 's/${{ env.README_VERSION_PLACEHOLDER }}/${{ env.RELEASE_VERSION }}/g' ${{ github.event.inputs.agent }}/${{ env.README_TEMPLATE_FILE }} > ${{ github.event.inputs.agent }}/${{ env.README_FILE }} | |
git add ${{ github.event.inputs.agent }}/${{ env.README_FILE }} | |
git commit -m "Readme update" | |
- name: Update CHANGELOG.md | |
id: changelogUpdate | |
run: | | |
sed '/\[Unreleased\]/q' ${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_FILE }} >> ${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_TMP_FILE }} | |
sed -E '1,/#?#\s*\[Unreleased\]/d' ${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_FILE }} | sed -E '/#?#\s*\[/q' | \ | |
{ echo -e '\n## [${{env.RELEASE_VERSION}}]'; sed '$d'; } >> ${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_TMP_FILE }} | |
grep -E '#?#\s*\[[0-9]' ${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_FILE }} | head -n1 >> ${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_TMP_FILE }} | |
sed -E '1,/#?#\s*\[[0-9]/d' ${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_FILE }} >> ${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_TMP_FILE }} | |
rm ${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_FILE }} | |
mv ${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_TMP_FILE }} ${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_FILE }} | |
git add ${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_FILE }} | |
git commit -m "Changelog update" | |
git push | |
- name: Read changelog Entry | |
id: readChangelogEntry | |
uses: mindsers/changelog-reader-action@v2 | |
with: | |
version: ${{ env.RELEASE_VERSION }} | |
path: ./${{ github.event.inputs.agent }}/${{ env.CHANGE_LOG_FILE }} | |
- name: Create Release | |
id: createRelease | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ github.event.inputs.agent }}-${{ env.RELEASE_VERSION }} | |
name: Release ${{ github.event.inputs.agent }} ${{ env.RELEASE_VERSION }} | |
body: ${{ steps.readChangelogEntry.outputs.changes }} | |
- name: Checkout develop branch | |
if: ${{ github.ref }} == 'main' | |
uses: actions/checkout@v4 | |
with: | |
ref: 'develop' | |
fetch-depth: 0 | |
- name: Merge release branch into develop | |
id: mergeIntoDevelop | |
if: ${{ github.ref }} == 'main' | |
run: | | |
git merge -m 'Merge master branch into develop after a release' origin/main | |
git status | (! grep -Fq 'both modified:') || git status | grep -F 'both modified:' \ | |
| { echo -e 'Unable to merge master into develop, merge conflicts:'; (! grep -Eo '[^ ]+$') } | |
git push |