Skip to content

Commit

Permalink
Merge pull request #1847 from Adyen/chore/new_github_action_for_relea…
Browse files Browse the repository at this point in the history
…sing

Release - New GitHub workflow for releasing
  • Loading branch information
araratthehero authored Oct 24, 2024
2 parents 8b9f809 + 35e0439 commit 60c4259
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 12 deletions.
17 changes: 5 additions & 12 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
name: Publish Release

# Every time we merge to main branch we publish a release.
# Every time we trigger the workflow on a branch.
on:
push:
branches: [ main ]
workflow_dispatch:

jobs:

publish-release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: main

- name: Set up JDK
uses: actions/setup-java@v4
Expand All @@ -33,8 +29,6 @@ jobs:
- name: Gradle check
run: ./gradlew check

# TODO: add more tests or rely on check_release workflow?

# Base64 decodes and pipes the GPG key content into the secret file
- name: Prepare environment
env:
Expand All @@ -48,8 +42,8 @@ jobs:
- name: Publish to Maven Central
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 --stacktrace
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_USERNAME: ${{ secrets.OSSRH_TOKEN_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
Expand All @@ -73,9 +67,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commitish: main
tag_name: ${{ env.PROJECT_VERSION }}
release_name: ${{ env.PROJECT_VERSION }}
body_path: ${{ github.workspace }}/RELEASE_NOTES.md
draft: false
draft: true
prerelease: false
81 changes: 81 additions & 0 deletions .github/workflows/publish_release_old.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Publish Release - Old

# Every time we merge to main branch we publish a release.
on:
push:
branches: [ main ]
workflow_dispatch:

jobs:

publish-release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: main

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: true

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Gradle check
run: ./gradlew check

# TODO: add more tests or rely on check_release workflow?

# Base64 decodes and pipes the GPG key content into the secret file
- name: Prepare environment
env:
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
run: |
git fetch --unshallow
sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'"
# Packages and publishes to Maven Central
- name: Publish to Maven Central
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 --stacktrace
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}

# Get the version name from a script and save to environment variable.
- name: Set PROJECT_VERSION
run: |
echo "▸ Set run permission."
chmod +x scripts/version_name.sh
echo "▸ Getting version name"
PROJECT_VERSION=$(./scripts/version_name.sh)
echo "▸ Variable PROJECT_VERSION set to: ${PROJECT_VERSION}"
echo "▸ Adding PROJECT_VERSION variable with: $PROJECT_VERSION"
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
echo "▸ DONE"
# Create the Release TAG and notes.
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commitish: main
tag_name: ${{ env.PROJECT_VERSION }}
release_name: ${{ env.PROJECT_VERSION }}
body_path: ${{ github.workspace }}/RELEASE_NOTES.md
draft: false
prerelease: false

0 comments on commit 60c4259

Please sign in to comment.