Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: setup semantic release #28

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 34 additions & 28 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,44 @@ on:
pull_request:
branches:
- master
release:
types:
- published

jobs:
build:
permissions:
contents: write
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@d171c3b028d844f2bf14e9fdec0c58114451e4bf
- name: Generate a token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID_ADMIN_GITHUB }}
private_key: ${{ secrets.APP_PRIVATE_KEY_ADMIN_GITHUB }}
- uses: actions/checkout@v4
with:
token: ${{ steps.generate_token.outputs.token }}

- name: Verify Conventional Commits
uses: amannn/action-semantic-pull-request@v5
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up NodeJS
if: github.ref == 'refs/heads/master' # especificar rama principal
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Set up Semantic Release
if: github.ref == 'refs/heads/master' # especificar rama principal
run: npm -g install @semantic-release/git semantic-release@23.0.0
- name: Semantic Release
if: github.ref == 'refs/heads/master' # especificar rama principal
run: npx semantic-release@23.0.0
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand All @@ -45,27 +74,4 @@ jobs:
-Dsonar.login=${{ secrets.SONAR_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@d171c3b028d844f2bf14e9fdec0c58114451e4bf
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup Javadoc
run: ./gradlew clean build -x test -x check
- name: Prepare gpg key
run: |
mkdir -p ~/.gradle/
echo "${{secrets.SIGNING_KEY_FILE}}" | base64 -d > ~/.gradle/secring.gpg
- name: Publish Libraries
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Psigning.keyId=${{ secrets.SIGNING_KEY_ID }} -Psigning.password=${{ secrets.SIGNING_KEY_PASSWORD }} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg) --stacktrace
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.MAVEN_PASSWORD }}

65 changes: 65 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "release-actions"
on:
release:
types: [ released ]
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID_ADMIN_GITHUB }}
private_key: ${{ secrets.APP_PRIVATE_KEY_ADMIN_GITHUB }}
- uses: actions/checkout@v4
with:
token: ${{ steps.generate_token.outputs.token }}
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV

- name: Upgrade Gradle.properties
run: sed -i 's/version=.*/version=${{ env.RELEASE_VERSION }}/g' gradle.properties


- name: Generate Changelog
uses: heinrichreimer/github-changelog-generator-action@v2.3
with:
token: ${{ secrets.GITHUB_TOKEN }}
pullRequests: true
prWoLabels: true
issues: true
issuesWoLabels: true
stripGeneratorNotice: true


- name: Save version
uses: github-actions-x/commit@v2.9
with:
github-token: ${{ steps.generate_token.outputs.token }}
push-branch: "master" # Set the correct branch
commit-message: 'docs(version): Update version to ${{ env.RELEASE_VERSION }}' # Change RELEASE_VERSION by your own or none
force-add: "true"
force-push: "true"
files: CHANGELOG.md gradle.properties # List of changed files
name: Release Bot
email: release-bot@bancolombia.com.co

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup Javadoc
run: ./gradlew clean build -x test -x check
- name: Prepare gpg key
run: |
mkdir -p ~/.gradle/
echo "${{secrets.SIGNING_KEY_FILE}}" | base64 -d > ~/.gradle/secring.gpg
- name: Publish Libraries
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Psigning.keyId=${{ secrets.SIGNING_KEY_ID }} -Psigning.password=${{ secrets.SIGNING_KEY_PASSWORD }} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg) --stacktrace
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.MAVEN_PASSWORD }}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.11.0
14 changes: 14 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"branches": ["master"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/git",
{
"assets": [ { "path": "build/**/*.jar", "label": "Compiled files" }],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
}
Loading