-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(workflow): 🚀 added publish workflow to deploy to Maven central (#66)
* ci(workflow): 🚀 added publish workflow to deploy to Maven central Closes #14 * build(Internal): 🔖 updated base version of the framework to v0.0.0 First release will happen with v0.1.0 * v0.1.0 * Revert "v0.1.0" This reverts commit 7b2bc9c. * ci(Internal): 🔖 created workflow to publish to GitHub and Maven central * build(Internal): Update CodeQL Action v2 (#75) Updating CodeQL Action to V2 since V1 is being deprecated. Refs: https://github.blog/changelog/2022-04-27-code-scanning-deprecation-of-codeql-action-v1/ * ci(Internal): ⬆️ added publish workflow also upgraded outdated dependencies * docs(website): 📝 added documentation for publish workflow Co-authored-by: Diogo Mendes <diogo@ymail.com>
- Loading branch information
1 parent
5c3810b
commit 095a554
Showing
15 changed files
with
944 additions
and
36 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,312 @@ | ||
name: Deploy Release to GitHub and Maven Central | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_type: | ||
type: choice | ||
description: 'Release Type' | ||
required: true | ||
options: | ||
- major | ||
- minor | ||
- patch | ||
default: 'minor' | ||
|
||
env: | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} | ||
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} | ||
TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }} | ||
TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} | ||
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} | ||
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} | ||
|
||
jobs: | ||
prepare-release-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node v16 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn | ||
|
||
- name: Update version major | ||
if: ${{ github.event.inputs.release_type == 'major' }} | ||
run: yarn run major && yarn version $(node -pe "require('./website/package.json').version") | ||
|
||
- name: Update version minor | ||
if: ${{ github.event.inputs.release_type == 'minor' }} | ||
run: yarn run minor && yarn version $(node -pe "require('./website/package.json').version") | ||
|
||
- name: Update version patch | ||
if: ${{ github.event.inputs.release_type == 'patch' }} | ||
run: yarn run patch && yarn version $(node -pe "require('./website/package.json').version") | ||
|
||
- name: Upload updated package.json to artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: target | ||
path: | | ||
${{ github.workspace }}/.yarn | ||
${{ github.workspace }}/package.json | ||
${{ github.workspace }}/website/package.json | ||
maven-release-snapshot: | ||
runs-on: ubuntu-latest | ||
needs: prepare-release-version | ||
|
||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node v16 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
cache: 'yarn' | ||
|
||
- name: Install Java and Maven | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
|
||
- name: Restore local Maven repository | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ github.sha }} | ||
|
||
- name: Download artifacts data | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: target | ||
|
||
- name: Maven command to update snapshot version | ||
run: mvn build-helper:parse-version versions:set -f core-java/pom.xml -DnewVersion=$(node -pe "require('./package.json').version")-SNAPSHOT versions:commit | ||
|
||
- name: Build the artifacts | ||
run: mvn clean install -f core-java/pom.xml -DskipTests -Dcheckstyle.skip | ||
|
||
- name: Release snapshot to Maven central | ||
uses: samuelmeuli/action-maven-publish@v1 | ||
with: | ||
gpg_private_key: ${{ env.GPG_PRIVATE_KEY }} | ||
gpg_passphrase: ${{ env.GPG_PASSPHRASE }} | ||
nexus_username: ${{ env.NEXUS_USERNAME }} | ||
nexus_password: ${{ env.NEXUS_PASSWORD }} | ||
maven_profiles: release | ||
server_id: ossrh | ||
maven_args: --settings ${{ github.workspace }}/core-java/setting/settings.xml -f core-java/pom.xml -DskipTests -Dcheckstyle.skip -B | ||
|
||
- name: Upload target folder | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: target | ||
path: | | ||
${{ github.workspace }}/package.json | ||
${{ github.workspace }}/website/package.json | ||
${{ github.workspace }}/core-java/target | ||
${{ github.workspace }}/core-java/pom.xml | ||
maven-release: | ||
runs-on: ubuntu-latest | ||
needs: maven-release-snapshot | ||
|
||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
cache: 'yarn' | ||
|
||
- name: Install Java and Maven | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
|
||
- name: Restore local Maven repository | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ github.sha }} | ||
|
||
- name: Download artifacts data | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: target | ||
|
||
- name: Maven command to update snapshot version | ||
run: mvn build-helper:parse-version versions:set -f core-java/pom.xml -DnewVersion=$(node -pe "require('./package.json').version") versions:commit | ||
|
||
- name: Build the artifacts | ||
run: mvn clean install -f core-java/pom.xml -DskipTests -Dcheckstyle.skip | ||
|
||
- name: Release snapshot to Maven central | ||
uses: samuelmeuli/action-maven-publish@v1 | ||
with: | ||
gpg_private_key: ${{ env.GPG_PRIVATE_KEY }} | ||
gpg_passphrase: ${{ env.GPG_PASSPHRASE }} | ||
nexus_username: ${{ env.NEXUS_USERNAME }} | ||
nexus_password: ${{ env.NEXUS_PASSWORD }} | ||
maven_profiles: release | ||
server_id: ossrh | ||
maven_args: --settings ${{ github.workspace }}/core-java/setting/settings.xml -f core-java/pom.xml -DskipTests -Dcheckstyle.skip -B | ||
|
||
- name: Upload target folder | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: target | ||
path: | | ||
${{ github.workspace }}/package.json | ||
${{ github.workspace }}/website/package.json | ||
${{ github.workspace }}/core-java/target | ||
${{ github.workspace }}/core-java/pom.xml | ||
push-pom: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- maven-release | ||
|
||
outputs: | ||
release-version: ${{ steps.version.outputs.version }} | ||
release-changelog: ${{ steps.changelog.outputs.changelog }} | ||
|
||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Java and Maven | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
|
||
- name: Setup Node v16 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
cache: 'yarn' | ||
|
||
- name: Download target folder | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: target | ||
|
||
- name: Create GitHub Release changelog | ||
id: changelog | ||
run: | | ||
export CHANGELOG=$(yarn run changelog) | ||
echo "::set-output name=changelog::$CHANGELOG" | ||
- name: Get the release version | ||
id: version | ||
run: | | ||
export MVN_VERSION=$(node -pe "require('./package.json').version") | ||
echo "::set-output name=version::$MVN_VERSION" | ||
- name: Import GPG key | ||
uses: crazy-max/ghaction-import-gpg@v5 | ||
with: | ||
gpg-private-key: ${{ env.GPG_PRIVATE_KEY }} | ||
passphrase: ${{ env.GPG_PASSPHRASE }} | ||
git-user-signingkey: true | ||
git-commit-gpgsign: true | ||
|
||
- name: Push updated pom.xml | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
add: core-java/pom.xml | ||
message: Released latest version to Maven central | ||
push: true | ||
default_author: user_info | ||
signoff: true | ||
|
||
push-tag: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- push-pom | ||
|
||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download target folder | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: target | ||
|
||
- name: Import GPG key | ||
uses: crazy-max/ghaction-import-gpg@v5 | ||
with: | ||
gpg-private-key: ${{ env.GPG_PRIVATE_KEY }} | ||
passphrase: ${{ env.GPG_PASSPHRASE }} | ||
git-user-signingkey: true | ||
git-commit-gpgsign: true | ||
|
||
- name: Create and Push Tag | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
tag: v${{ needs.push-pom.outputs.release-version }} | ||
message: Released to Maven central | ||
signoff: true | ||
default_author: user_info | ||
push: true | ||
|
||
github-release-tweet: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- push-pom | ||
- push-tag | ||
|
||
outputs: | ||
changelog: ${{ steps.artifacts.outputs.changelog }} | ||
|
||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download target folder | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: target | ||
|
||
- name: Create GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
id: release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
GITHUB_REPOSITORY: ${{ github.repository }} | ||
with: | ||
tag_name: v${{ needs.push-pom.outputs.release-version }} | ||
name: Version ${{ needs.push-pom.outputs.release-version }} | ||
prerelease: false | ||
draft: false | ||
body: v${{ needs.push-pom.outputs.release-changelog }} | ||
discussion_category_name: Announcements | ||
generate_release_notes: false | ||
files: | | ||
core-java/target/*.jar | ||
core-java/target/*.pom | ||
- name: Send Release Tweet | ||
uses: ethomson/send-tweet-action@v1 | ||
with: | ||
status: | | ||
🎊 ✨ Released v${{ needs.push-pom.outputs.release-version }} for #BoykaFramework\n\nCheck it out at ${{ steps.release.outputs.url }} | ||
consumer-key: ${{ env.TWITTER_CONSUMER_API_KEY }} | ||
consumer-secret: ${{ env.TWITTER_CONSUMER_API_SECRET }} | ||
access-token: ${{ env.TWITTER_ACCESS_TOKEN }} | ||
access-token-secret: ${{ env.TWITTER_ACCESS_TOKEN_SECRET }} |
Oops, something went wrong.