Skip to content

Commit

Permalink
Merge pull request #1883 from Adyen/chore/release_process_version_number
Browse files Browse the repository at this point in the history
Release process - version number
  • Loading branch information
OscarSpruit authored Nov 8, 2024
2 parents 4d1a10d + 53f0107 commit 17af293
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 129 deletions.
30 changes: 6 additions & 24 deletions .github/workflows/create_github_release.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,15 @@
name: Create github release

on:
workflow_call
workflow_call:
inputs:
version-name:
required: true
type: string

jobs:
generate_version_name:
runs-on: ubuntu-latest

outputs:
version_name: ${{ steps.version_name.outputs.PROJECT_VERSION }}

steps:
- uses: actions/checkout@v4

# Get the version name from a script and save it in version_name output.
- name: Generate version_name
id: version_name
run: |
echo "▸ Set run permission."
chmod +x scripts/version_name.sh
echo "▸ Getting version name"
PROJECT_VERSION=$(./scripts/version_name.sh)
echo "▸ Creating the version_name output with value: $PROJECT_VERSION"
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_OUTPUT
echo "▸ DONE"
create_github_release:
runs-on: ubuntu-latest
needs: generate_version_name

steps:
- uses: actions/checkout@v4
Expand All @@ -37,7 +19,7 @@ jobs:
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION_NAME: ${{ needs.generate_version_name.outputs.version_name }}
VERSION_NAME: ${{ inputs.version-name }}
with:
token: ${{ env.GITHUB_TOKEN }}
tag: ${{ env.VERSION_NAME }}
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/generate_version_name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Generate version name

on:
workflow_call:
outputs:
version-name:
description: "The version name of the current release"
value: ${{ jobs.generate_version_name.outputs.version-name }}

jobs:
generate_version_name:
runs-on: ubuntu-latest
outputs:
version-name: ${{ steps.generate_version_name.outputs.version_name }}

steps:
- uses: actions/checkout@v4
- name: Generate version name
id: generate_version_name
run: |
chmod +x scripts/version_name.sh
VERSION_NAME=$(./scripts/version_name.sh)
echo "version_name=$VERSION_NAME" >> $GITHUB_OUTPUT
echo $VERSION_NAME
11 changes: 9 additions & 2 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ jobs:
check:
name: Check
uses: ./.github/workflows/check.yml
generate_version_name:
name: Generate version name
uses: ./.github/workflows/generate_version_name.yml
publish_to_maven_central:
name: Publish to Maven Central
uses: ./.github/workflows/publish_to_maven_central.yml
secrets: inherit
needs: check
needs: [generate_version_name, check]
with:
version-name: ${{ needs.generate_version_name.outputs.version-name }}
create_github_release:
name: Create GitHub Release
uses: ./.github/workflows/create_github_release.yml
secrets: inherit
needs: publish_to_maven_central
needs: [generate_version_name, publish_to_maven_central]
with:
version-name: ${{ needs.generate_version_name.outputs.version-name }}
81 changes: 0 additions & 81 deletions .github/workflows/publish_release_old.yml

This file was deleted.

9 changes: 7 additions & 2 deletions .github/workflows/publish_to_maven_central.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: Publish to Maven Central

on:
workflow_call
workflow_call:
inputs:
version-name:
required: true
type: string

jobs:
publish_to_maven_central:
Expand Down Expand Up @@ -30,11 +34,12 @@ jobs:
# Packages and publishes to Maven Central
- name: Publish to Maven Central
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 --stacktrace
env:
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 }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
VERSION_NAME: ${{ inputs.version-name }}
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 --stacktrace -Pversion-name=$VERSION_NAME
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@ Import the corresponding module in your `build.gradle` file.

For Drop-in:
```groovy
implementation "com.adyen.checkout:drop-in-compose:5.7.0"
implementation "com.adyen.checkout:drop-in-compose:LATEST_VERSION"
```
For the Credit Card component:
```groovy
implementation "com.adyen.checkout:card:5.7.0"
implementation "com.adyen.checkout:components-compose:5.7.0"
implementation "com.adyen.checkout:card:LATEST_VERSION"
implementation "com.adyen.checkout:components-compose:LATEST_VERSION"
```

### Without Jetpack Compose

For Drop-in:
```groovy
implementation "com.adyen.checkout:drop-in:5.7.0"
implementation "com.adyen.checkout:drop-in:LATEST_VERSION"
```
For the Credit Card component:
```groovy
implementation "com.adyen.checkout:card:5.7.0"
implementation "com.adyen.checkout:card:LATEST_VERSION"
```

The library is available on [Maven Central][mavenRepo].
Find out what the latest version is [here](https://github.com/Adyen/adyen-android/releases/latest). The library is available on [Maven Central][mavenRepo].

## Additional documentation

Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ apply from: "config/gradle/sonarcloud.gradle"
apply from: "config/gradle/apiValidator.gradle"

ext {
if (project.hasProperty("version-name")) {
versionName = project.property("version-name")
} else {
versionName = "develop"
}
checkoutRedirectScheme = "adyencheckout"
}

Expand Down
2 changes: 1 addition & 1 deletion config/gradle/buildConfig.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

android {
defaultConfig {
buildConfigField "String", "CHECKOUT_VERSION", "\"${libs.versions.version.name.get()}\""
buildConfigField "String", "CHECKOUT_VERSION", "\"$rootProject.ext.versionName\""
}

buildFeatures {
Expand Down
2 changes: 1 addition & 1 deletion config/gradle/release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if (secretPropsFile.exists()) {

final theGroupId = "com.adyen.checkout"
final theArtifactId = project.mavenArtifactId
final theVersion = libs.versions.version.name.get()
final theVersion = rootProject.ext.versionName

final theName = project.mavenArtifactName
final theDescription = project.mavenArtifactDescription
Expand Down
6 changes: 3 additions & 3 deletions example-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ android {
minSdk libs.versions.min.sdk.get().toInteger()
targetSdk libs.versions.target.sdk.get().toInteger()
versionCode libs.versions.version.code.get().toInteger()
versionName libs.versions.version.name.get()
versionName rootProject.ext.versionName

testInstrumentationRunner 'com.adyen.checkout.test.HiltTestRunner'
}
Expand Down Expand Up @@ -71,8 +71,8 @@ dependencies {
// Checkout
implementation project(':drop-in')
implementation project(':components-compose')
// implementation "com.adyen.checkout:drop-in:5.7.0"
// implementation "com.adyen.checkout:components-compose:5.7.0"
// implementation "com.adyen.checkout:drop-in:LATEST_VERSION"
// implementation "com.adyen.checkout:components-compose:LATEST_VERSION"

// Dependencies
implementation libs.bundles.kotlin.coroutines
Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ min-sdk = "21"

# App version, only used for example app, no need to increment
version-code = "1"
# The version-name format is "major.minor.patch(-(alpha|beta|rc)[0-9]{2}){0,1}" (e.g. 3.0.0, 3.1.1-alpha04 or 3.1.4-rc01 etc).
version-name = "5.7.0"

# Build script
android-gradle-plugin = "8.7.1"
Expand Down
18 changes: 11 additions & 7 deletions scripts/version_name.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#!/bin/bash

function release_version() {
local build_file="${GITHUB_WORKSPACE}/gradle/libs.versions.toml"
local version_name_key="version-name"
local version_name_regex="^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(-(alpha|beta|rc)[0-9]{2}){0,1}$"
local branch_name=$(git branch --show-current)

if [[ $branch_name != release/* ]]; then
echo "Error: invalid branch name. Branch name should start with \"release/\"."
exit 1
fi

local version=$(sed -n "s/.*${version_name_key}[[:space:]]*=[[:space:]]*[\"\']\(.*\)[\"\'].*/\1/p" ${build_file})
local version_name="${branch_name#*release/}"
local version_name_regex="^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(-(alpha|beta|rc)[0-9]{2}){0,1}$"

if [[ ! ${version} =~ ${version_name_regex} ]]; then
echo "Error: invalid version name [$version], please validate that [$version_name_key] at [$build_file] follows regex $version_name_regex ."
if [[ ! ${version_name} =~ ${version_name_regex} ]]; then
echo "Error: invalid version name: $version_name. Please make sure that the name follows this pattern: $version_name_regex ."
exit 1
fi

echo "$version"
echo "$version_name"
}

release_version

0 comments on commit 17af293

Please sign in to comment.