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(release): implementing semantic release (#47) #48

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
57 changes: 31 additions & 26 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,42 @@ on:
pull_request:
branches:
- main
release:
types:
- published

jobs:
build:
permissions:
contents: write
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- 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/main' # especificar rama principal
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Set up Semantic Release
if: github.ref == 'refs/heads/main' # especificar rama principal
run: npm -g install @semantic-release/git semantic-release@23.0.0
- name: Semantic Release
if: github.ref == 'refs/heads/main' # especificar rama principal
run: npx semantic-release@23.0.0
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} # debe crear un Personal Access Token
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
Expand All @@ -39,25 +66,3 @@ 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@v3
- 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: 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)
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.MAVEN_PASSWORD }}
57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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: "main" # 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 README.md gradle.properties src/main/java/co/com/bancolombia/Constants.java # 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: 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)
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"], # especificar la rama principal
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/git",
{
"assets": [ { "path": "build/**/*", "label": "Compiled files" }], # cambiar path por la ruta con el compilado de la app
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
}
Loading