Skip to content

Commit

Permalink
IJMP-1873 Kotlin SDK docs update + license header update + GitHub Act…
Browse files Browse the repository at this point in the history
…ions build workflow

Signed-off-by: Uladzislau <[email protected]>
  • Loading branch information
KUGDev committed Sep 5, 2024
1 parent 8dabecf commit 04f462a
Show file tree
Hide file tree
Showing 152 changed files with 2,580 additions and 288 deletions.
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runs:
using: "composite"
steps:
- name: Set up JDK ${{ inputs.jdkVersion }}
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ inputs.jdkVersion }}
Expand All @@ -21,7 +21,7 @@ runs:
shell: bash

- name: Cache Gradle packages
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build + Test + Sonar

on: [push, workflow_dispatch]

permissions:
contents: read

jobs:
build_and_test:
runs-on: ubuntu-latest
timeout-minutes: 40

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.ZOWE_ROBOT_TOKEN }}

- uses: ./.github/actions/setup

- name: Build with Gradle
run: ./gradlew build

- name: Prepare lib Artifact
id: artifact
shell: bash
run: |
cd ${{ github.workspace }}/build/libs
FILENAME=`ls | grep -vE '(-javadoc|-sources)\.jar$'`
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
echo "zip artifact name:"
echo "$FILENAME"
- name: Publish built lib to artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact.outputs.filename }}
path: ./build/libs/*

- name: Test with Gradle
run: ./gradlew test

- name: Publish tests result to artifacts
uses: actions/upload-artifact@v4
with:
name: tests-report-${{ steps.artifact.outputs.filename }}
path: ${{ github.workspace }}/build/reports/*

- name: Publish results to SonarCloud
run: >
./gradlew --info sonar -Dresults="build/reports/tests/test,build/test-results"
-Psonar.host.url=$SONAR_HOST_URL -Dsonar.token=$SONAR_TOKEN
-Partifactory_user=$ARTIFACTORY_USERNAME -Partifactory_password=$ARTIFACTORY_PASSWORD
-Dsonar.coverage.jacoco.xmlReportPaths="build/reports/jacoco.xml"
env:
ARTIFACTORY_USE RNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: ./.github/actions/teardown
221 changes: 199 additions & 22 deletions .github/workflows/release-new-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
name: Release new binary version manually

on:
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
workflow_dispatch:

jobs:
release:
changelog-and-preparations:
runs-on: ubuntu-latest
timeout-minutes: 40

permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v3

- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.ZOWE_ROBOT_TOKEN }}
Expand All @@ -24,22 +22,201 @@ jobs:
- name: Build with Gradle
run: ./gradlew build

- name: Fetch Gradle properties
id: properties
shell: bash
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
VERSION_FULL="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
CURR_COMMIT="$(git rev-parse HEAD)"
echo "versionSemVer: $VERSION_FULL"
echo "currCommit: $CURR_COMMIT"
echo "versionSemVer=$VERSION_FULL" >> $GITHUB_OUTPUT
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: Build new docs with Dokka and publish to the docs branch
run: |
VERSION="${{ steps.properties.outputs.versionSemVer }}"
git checkout -b docs
echo "=== Preparing the docs ==="
./gradlew dokkaHtml
echo "=== Setting up docs/version path ==="
if [ ! -d "docs" ]; then
mkdir -m 755 "docs"
fi
if [ -d "docs/$VERSION" ]; then
rm -rf "docs/$VERSION"
fi
mkdir -m 755 "docs/$VERSION"
echo "=== Moving the built docs ==="
mv build/dokka/html/* "docs/$VERSION"
echo "=== 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: /docs/$VERSION/" >> $TEMP_FILE
echo "---" >> $TEMP_FILE
echo "" >> $TEMP_FILE
cat "docs/$VERSION/index.html" >> $TEMP_FILE
mv $TEMP_FILE "docs/$VERSION/index.html"
echo "=== Writing docs-related lines to the README_FOR_DOCS.md"
TEMP_FILE=$(mktemp)
echo "---" >> $TEMP_FILE
echo "id: home" >> $TEMP_FILE
echo "layout: default" >> $TEMP_FILE
echo "title: Home" >> $TEMP_FILE
echo "permalink: /" >> $TEMP_FILE
echo "---" >> $TEMP_FILE
echo "" >> $TEMP_FILE
echo "# [Click here](https://zowe.github.io/zowe-client-kotlin-sdk/docs/$VERSION) to go to the Zowe Client Kotlin SDK source code docs" >> $TEMP_FILE
echo "" >> $TEMP_FILE
echo "---" >> $TEMP_FILE
echo "" >> $TEMP_FILE
cat "README_FOR_DOCS.md" >> $TEMP_FILE
mv $TEMP_FILE README_FOR_DOCS.md
echo "=== Committing the docs ==="
git add .
git status
git commit -am "Docs for v$VERSION"
git push --set-upstream origin docs -f
# - 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

# # 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"

- name: Set email
run: git config user.email "[email protected]"
# # Moving the built docs
# mv build/dokka/html/* "docs/$VERSION"

- name: Set name
run: git config user.name "For Mainframe"
# # 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: 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: 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
38 changes: 0 additions & 38 deletions .github/workflows/sonar-scan.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
_site
.sass-cache
.jekyll-cache
.jekyll-metadata
vendor
.idea
.idea/*.xml
.idea/*.iml
.idea/modules
Expand Down
25 changes: 25 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
id: not-found
permalink: /404.html
layout: default
---

<style type="text/css" media="screen">
.container-404 {
margin: 10px auto;
text-align: center;
}
.h1-404 {
margin: 30px 0;
font-size: 4em;
line-height: 1;
letter-spacing: -1px;
}
</style>

<div class="container-404">
<h1 class="h1-404">404</h1>

<p><strong>Page not found :(</strong></p>
<p>The requested page could not be found.</p>
</div>
Loading

0 comments on commit 04f462a

Please sign in to comment.