Skip to content

Commit

Permalink
Merge branch 'release/v0.5.0' into docs
Browse files Browse the repository at this point in the history
Signed-off-by: Uladzislau <[email protected]>
  • Loading branch information
KUGDev committed Sep 5, 2024
2 parents fdc2ae2 + da96978 commit b2e98e7
Showing 1 changed file with 112 additions and 148 deletions.
260 changes: 112 additions & 148 deletions .github/workflows/release-new-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,91 +37,21 @@ jobs:
echo "currCommit=$CURR_COMMIT" >> $GITHUB_OUTPUT
- name: Clean git
run: git reset --hard HEAD
run: |
git reset --hard HEAD
git pull
- name: Set email and user name
run: |
git config user.email "[email protected]"
git config user.name "For Mainframe"
# - name: Release with Gradle automatic
# run: ./gradlew release -x test -x updateVersion -x commitNewVersion -Prelease.useAutomaticVersion=true -Prelease.scope=${{ github.event.inputs.scope || env.DEFAULT_SCOPE }} -Pzowe.deploy.username=$ARTIFACTORY_USERNAME -Pzowe.deploy.password=$ARTIFACTORY_PASSWORD -Partifactory_user=$ARTIFACTORY_USERNAME -Partifactory_password=$ARTIFACTORY_USERNAME
# env:
# ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
# ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
# DEFAULT_SCOPE: 'patch'
# BUILD_NUMBER: ${{ github.run_number }}
# BRANCH_NAME: ${{ github.ref_name }}

- name: Prepare changelog
shell: bash
run: ./gradlew patchChangelog

- name: Prepare release notes
id: release_notes
shell: bash
run: |
CHANGELOG="$(./gradlew getChangelog -q)"
echo 'version_release_notes<<EOF' >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo "Release notes to be added:"
echo "$CHANGELOG"
- name: Create new release and upload build artifacts
if: ${{ !contains(steps.properties.outputs.versionSemVer, '-rc') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ steps.properties.outputs.versionSemVer }} --title ${{ steps.properties.outputs.versionSemVer }} --target ${{ steps.properties.outputs.currCommit }} -F- <<EOF
${{ steps.release_notes.outputs.version_release_notes }}
EOF
gh release upload ${{ steps.properties.outputs.versionSemVer }} ./build/libs/*
- name: Bump version in gradle.properties
run: |
# Read current version in gradle.properties
current_version=$(grep -E "^version=" gradle.properties | cut -d'=' -f2)
echo "Current version: $current_version"
# Splitting the prefix and the last number
prefix=$(echo "$current_version" | sed 's/[0-9]*$//') # Leave prefix without the last number
last_number=$(echo "$current_version" | grep -oE '[0-9]+$') # Fetching the number
new_number=$((last_number + 1))
new_version="${prefix}${new_number}"
echo "New version: $new_version"
# Update version in gradle.properties
sed -i "s/^version=.*/version=${new_version}/" gradle.properties
echo "gradle.properties after change:"
cat gradle.properties
- name: Push changes to the release branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.properties.outputs.versionSemVer }}"
git config user.email "[email protected]"
git config user.name "GitHub Action"
git add gradle.properties
# No need to change CHANGELOG in -rc. builds
if [[ "$VERSION" == *"-rc"* ]]; then
git restore CHANGELOG.md
fi
git commit -am ":moyai: ${VERSION}" -m "[skip ci]"
git push
- name: Build new docs with Dokka and publish to the docs branch
run: |
VERSION="${{ steps.properties.outputs.versionSemVer }}"
# git pull origin docs
# git status
git checkout docs
git merge release/v0.5.0
Expand Down Expand Up @@ -152,89 +82,123 @@ jobs:
cat "docs/$VERSION/index.html" >> $TEMP_FILE
mv $TEMP_FILE "docs/$VERSION/index.html"
- name: Close Milestone
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/{owner}/{repo}/milestones \
--jq '.[] | select(.title == "${{ steps.properties.outputs.versionSemVer }}") | .number' \
| xargs -I '{}' gh api -X PATCH repos/{owner}/{repo}/milestones/{} -F state='closed'
- name: Prepare changelog
shell: bash
run: ./gradlew patchChangelog

- name: Prepare release notes
id: release_notes
shell: bash
run: |
CHANGELOG="$(./gradlew getChangelog -q)"
echo 'version_release_notes<<EOF' >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
# - name: Release with Gradle automatic
# run: ./gradlew release -x test -x updateVersion -x commitNewVersion -Prelease.useAutomaticVersion=true -Prelease.scope=${{ github.event.inputs.scope || env.DEFAULT_SCOPE }} -Pzowe.deploy.username=$ARTIFACTORY_USERNAME -Pzowe.deploy.password=$ARTIFACTORY_PASSWORD -Partifactory_user=$ARTIFACTORY_USERNAME -Partifactory_password=$ARTIFACTORY_USERNAME
# env:
# ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
# ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
# DEFAULT_SCOPE: 'patch'
# BUILD_NUMBER: ${{ github.run_number }}
# BRANCH_NAME: ${{ github.ref_name }}

echo "Release notes to be added:"
echo "$CHANGELOG"
# - name: Prepare changelog
# shell: bash
# run: ./gradlew patchChangelog

- name: Create new release and upload build artifacts
if: ${{ !contains(steps.properties.outputs.versionSemVer, '-rc') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ steps.properties.outputs.versionSemVer }} --title ${{ steps.properties.outputs.versionSemVer }} --target ${{ steps.properties.outputs.currCommit }} -F- <<EOF
${{ steps.release_notes.outputs.version_release_notes }}
EOF
# - name: Prepare release notes
# id: release_notes
# shell: bash
# run: |
# CHANGELOG="$(./gradlew getChangelog -q)"

gh release upload ${{ steps.properties.outputs.versionSemVer }} ./build/libs/*
# echo 'version_release_notes<<EOF' >> $GITHUB_OUTPUT
# echo "$CHANGELOG" >> $GITHUB_OUTPUT
# echo 'EOF' >> $GITHUB_OUTPUT

- name: Bump version in gradle.properties
run: |
# Read current version in gradle.properties
current_version=$(grep -E "^version=" gradle.properties | cut -d'=' -f2)
echo "Current version: $current_version"
# echo "Release notes to be added:"
# echo "$CHANGELOG"

# Splitting the prefix and the last number
prefix=$(echo "$current_version" | sed 's/[0-9]*$//') # Leave prefix without the last number
last_number=$(echo "$current_version" | grep -oE '[0-9]+$') # Fetching the number
new_number=$((last_number + 1))
new_version="${prefix}${new_number}"
# - name: Create new release and upload build artifacts
# if: ${{ !contains(steps.properties.outputs.versionSemVer, '-rc') }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# gh release create ${{ steps.properties.outputs.versionSemVer }} --title ${{ steps.properties.outputs.versionSemVer }} --target ${{ steps.properties.outputs.currCommit }} -F- <<EOF
# ${{ steps.release_notes.outputs.version_release_notes }}
# EOF

echo "New version: $new_version"
# gh release upload ${{ steps.properties.outputs.versionSemVer }} ./build/libs/*

# Update version in gradle.properties
sed -i "s/^version=.*/version=${new_version}/" gradle.properties
# - name: Bump version in gradle.properties
# run: |
# # Read current version in gradle.properties
# current_version=$(grep -E "^version=" gradle.properties | cut -d'=' -f2)
# echo "Current version: $current_version"

echo "gradle.properties after change:"
cat gradle.properties
# # Splitting the prefix and the last number
# prefix=$(echo "$current_version" | sed 's/[0-9]*$//') # Leave prefix without the last number
# last_number=$(echo "$current_version" | grep -oE '[0-9]+$') # Fetching the number
# new_number=$((last_number + 1))
# new_version="${prefix}${new_number}"

- name: Create branch with CHANGELOG changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.properties.outputs.versionSemVer }}"
BRANCH="release-changelog-update-$VERSION"
# echo "New version: $new_version"

git config user.email "[email protected]"
git config user.name "GitHub Action"
# # Update version in gradle.properties
# sed -i "s/^version=.*/version=${new_version}/" gradle.properties

git checkout -b $BRANCH
git add gradle.properties
# No need to change CHANGELOG in -rc. builds
if [[ "$VERSION" == *"-rc"* ]]; then
git restore CHANGELOG.md
fi
git commit -am ":moyai: ${VERSION}" -m "[skip ci]"
git push --set-upstream origin $BRANCH
# echo "gradle.properties after change:"
# cat gradle.properties

- name: Close Milestone
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/{owner}/{repo}/milestones \
--jq '.[] | select(.title == "${{ steps.properties.outputs.versionSemVer }}") | .number' \
| xargs -I '{}' gh api -X PATCH repos/{owner}/{repo}/milestones/{} -F state='closed'
# - name: Push changes to the release branch
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# VERSION="${{ steps.properties.outputs.versionSemVer }}"

# git config user.email "[email protected]"
# git config user.name "GitHub Action"

# git add gradle.properties
# # No need to change CHANGELOG in -rc. builds
# if [[ "$VERSION" == *"-rc"* ]]; then
# git restore CHANGELOG.md
# fi
# git commit -am ":moyai: ${VERSION}" -m "[skip ci]"
# git push

# - name: Build new docs with Dokka and publish to the docs branch
# run: |
# VERSION="${{ steps.properties.outputs.versionSemVer }}"

# git pull origin docs
# git status
# # git checkout docs

# git merge release/v0.5.0

# # Preparing the docs
# ./gradlew dokkaHtml

# # Setting up docs/version path
# if [ ! -d "docs" ]; then
# mkdir -m 644 "docs"
# fi
# if [ -d "docs/$VERSION"]; then
# rm -rf "docs/$VERSION"
# fi
# mkdir -m 644 "docs/$VERSION"

# # Moving the built docs
# mv build/dokka/html/* "docs/$VERSION"

# # Writing Jekyll-related things to the index.html
# TEMP_FILE=$(mktemp)
# echo "---" >> $TEMP_FILE
# echo "id: zowe-client-kotlin-sdk-docs" >> $TEMP_FILE
# echo "title: Zowe Client Kotlin SDK docs" >> $TEMP_FILE
# echo "permalink: /$VERSION/docs/" >> $TEMP_FILE
# echo "---" >> $TEMP_FILE
# echo "" >> $TEMP_FILE
# cat "docs/$VERSION/index.html" >> $TEMP_FILE
# mv $TEMP_FILE "docs/$VERSION/index.html"

# - name: Close Milestone
# continue-on-error: true
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# gh api repos/{owner}/{repo}/milestones \
# --jq '.[] | select(.title == "${{ steps.properties.outputs.versionSemVer }}") | .number' \
# | xargs -I '{}' gh api -X PATCH repos/{owner}/{repo}/milestones/{} -F state='closed'

- uses: ./.github/actions/teardown
# - uses: ./.github/actions/teardown

0 comments on commit b2e98e7

Please sign in to comment.