Skip to content

Commit 9e301e6

Browse files
committed
ci: deploy stuff
1 parent dc8c49a commit 9e301e6

2 files changed

Lines changed: 121 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support documentation.
4+
# This workflow will download a prebuilt Java version, install dependencies, build and deploy/publish a new release
5+
# For more information see: https://docs.github.com/en/actions/guides/building-and-testing-java-with-maven
6+
7+
name: Deploy and Publish
8+
9+
on:
10+
push:
11+
branches: [ '**' ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
jobs:
17+
deploy:
18+
if: "!contains(github.event.head_commit.message, 'skip ci')"
19+
name: Deploy and Publish
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
with:
25+
persist-credentials: false
26+
27+
- name: Set up Java
28+
uses: actions/setup-java@v2
29+
with:
30+
java-version: '8'
31+
distribution: 'adopt'
32+
33+
- name: Build Java package
34+
env:
35+
MVN_ARGS: '-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
36+
run: mvn verify -fae -DskipITs -Dskip.unit.tests $MVN_ARGS
37+
38+
- name: Setup Node
39+
uses: actions/setup-node@v1
40+
with:
41+
node-version: 12
42+
43+
- name: Install Semantic Release dependencies
44+
run: |
45+
sudo apt-get install bumpversion
46+
npm install -g semantic-release
47+
npm install -g @semantic-release/changelog
48+
npm install -g @semantic-release/exec
49+
npm install -g @semantic-release/git
50+
npm install -g @semantic-release/github
51+
npm install -g @semantic-release/commit-analyzer
52+
npm install -g @semantic-release/release-notes-generator
53+
54+
- name: Publish Java docs
55+
env:
56+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
57+
GHA_REPO_SLUG: ${{ github.repository }}
58+
GHA_BRANCH: ${{ github.ref }} # non PR only need to get last part
59+
# GHA_PULL_REQUEST: ${{ github.event.number }}
60+
GHA_PULL_REQUEST: 'true'
61+
GHA_BUILD_NUMBER: ${{ github.run_number }}
62+
GHA_JOB_NUMBER: ${{ github.job_number }}
63+
GHA_COMMIT: ${{ github.sha }}
64+
GHA_TAG: ${{ github.event.release.tag_name }}
65+
# TRAVIS_TAG: ${{ github.event.release.tag_name }}
66+
run: |
67+
build/setMavenVersion.sh
68+
mvn clean javadoc:aggregate
69+
build/publish_gha.sh

build/publish_gha.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
# This script will publish the aggregated javadocs found in the project's "target" directory.
4+
# The javadocs are committed and pushed to the git repository's gh-pages branch.
5+
# Be sure to customize this file to reflect your SDK project's settings (git url,
6+
7+
# Avoid publishing javadocs for a PR build
8+
if [ "$GHA_PULL_REQUEST" == "false" ] && [ "$GHA_BRANCH" ]; then
9+
export GHA_BRANCH=${GHA_BRANCH##*/} # Get the last part for true branch name - "refs/heads/9260_gha"
10+
printf "\n>>>>> Publishing javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s pr=%s tag=%s commit=%s\n" ${GHA_REPO_SLUG} ${GHA_BRANCH} ${GHA_BUILD_NUMBER} ${GHA_JOB_NUMBER} ${GHA_PULL_REQUEST} ${GHA_TAG} ${GHA_COMMIT}
11+
12+
printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'\n"
13+
rm -fr ./gh-pages
14+
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/watson-developer-cloud/java-sdk.git gh-pages > /dev/null
15+
16+
printf "\n>>>>> Finished cloning...\n"
17+
18+
pushd gh-pages
19+
20+
# Create a new directory for this branch/tag and copy the aggregated javadocs there.
21+
printf "\n>>>>> Copying aggregated javadocs to new tagged-release directory: %s\n" ${GHA_BRANCH}
22+
rm -rf docs/${GHA_BRANCH}
23+
mkdir -p docs/${GHA_BRANCH}
24+
cp -rf ../target/site/apidocs/* docs/${GHA_BRANCH}
25+
26+
printf "\n>>>>> Generating gh-pages index.html...\n"
27+
../build/generateJavadocIndex.sh > index.html
28+
29+
# Update the 'latest' symlink to point to this branch if it's a tagged release.
30+
if [ -n "$GHA_TAG" ]; then
31+
pushd docs
32+
rm latest
33+
ln -s ./${GHA_TAG} latest
34+
printf "\n>>>>> Updated 'docs/latest' symlink:\n"
35+
ls -l latest
36+
popd
37+
fi
38+
39+
printf "\n>>>>> Committing new javadoc...\n"
40+
git add -f .
41+
git commit -m "Javadoc for release ${GHA_TAG} (${GHA_COMMIT})"
42+
git push -f origin gh-pages
43+
44+
popd
45+
46+
printf "\n>>>>> Published javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${GHA_REPO_SLUG} ${GHA_BRANCH} ${GHA_BUILD_NUMBER} ${GHA_JOB_NUMBER}
47+
48+
else
49+
50+
printf "\n>>>>> Javadoc publishing bypassed for non-release build: repo=%s branch=%s build_num=%s job_num=%s pr=%s tag=%s commit=%s\n" ${GHA_REPO_SLUG} ${GHA_BRANCH} ${GHA_BUILD_NUMBER} ${GHA_JOB_NUMBER} ${GHA_PULL_REQUEST} ${GHA_TAG} ${GHA_COMMIT}
51+
52+
fi

0 commit comments

Comments
 (0)