Skip to content

Commit

Permalink
Merge pull request #7 from PAYONE-GmbH/refactor/release-flow
Browse files Browse the repository at this point in the history
refactor/release flow
  • Loading branch information
lrosenfeldt authored Jul 31, 2024
2 parents e692d14 + d864f9c commit 5044dad
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ For a general introduction to the API and the different checkout flows see the d

## Table of Contents

- [Introduction](#introduction)
- [Requirements](#requirements)
- [Installation](#installation)
- [Demo App](#demo-app)
- [API Reference](#api-reference)
- [CommunicatorConfiguration](#communicatorconfiguration)
Expand Down Expand Up @@ -78,6 +78,26 @@ For a general introduction to the API and the different checkout flows see the d

PHP 8.2 or above is required.

## Installation

This SDK is currently not released on [packagist](https://packagist.org/). You can install it from GitHub by specifying a `vcs` repository within your `composer.json`:

```json
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/igorw/monolog"
}
],
"require": {
"payone-gmbh/pcp-serversdk-php": "main"
}
}
```

This snippets specify the main branch which contains the latest release. You can specify a version by inserting a git tag `vX.Y.Z` instead of `main`.

## Demo App

This repo contains a demo app that showcases how to implement a [Step-by-Step Checkout](https://docs.payone.com/pcp/checkout-flows/step-by-step-checkout) and a [One-Stop-Checkout](https://docs.payone.com/pcp/checkout-flows/one-step-checkout).
Expand Down Expand Up @@ -999,3 +1019,9 @@ This repository consists out of the following components:
1. The source code of the SDK itself: `/src`
2. The source code of the unit and integration tests (including the examples): `/tests`
3. The source code for demos is located `examples/*`. Make sure to run `composer install` and `composer dumb-autoload` before. Within the specific demo before launching it.

### Release

This SDK follows semver for versioning. To relase a new version create a branch `release/X.Y.Z` and run `prepare_release.sh X.Y.Z`. The script automatically replaces the `SDK_VERSION` property within the `CommunicatorConfiguration` class and version field in the root `composer.json` file. After that it commits the changes and tags the commit as `vX.Y.Z`.

This branch should then merged into `develop` and immediately into `main` after that.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"name": "PAYONE GmbH"
}
],
"version": "0.0.1",
"require": {
"php": "~8.2||~8.3",
"ext-curl": "*",
Expand Down
43 changes: 43 additions & 0 deletions prepare_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

VERSION=$1

# Check if an argument is provided
if [ -z "$VERSION" ]; then
echo "Error: No version number provided."
echo "Usage: $0 <version>"
exit 1
fi

# Check if the argument matches the format int.int.int
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Valid version number: $VERSION"
else
echo "Error: Invalid version number format."
echo "Usage: $0 <version>"
exit 1
fi

# tag should start with a 'v'
TAG="v${VERSION}"
COMMUNICATOR_CONFIG_CLASS_PATH="./src/PayoneCommercePlatform/Sdk/CommunicatorConfiguration.php"
COMPOSER_JSON_PATH="./composer.json"

SED_COMMUNICATOR_CONFIG_CMD=$(printf 's/public const SDK_VERSION = .[0-9]*\.[0-9]*\.[0-9]*./public const SDK_VERSION = %s/' "'${VERSION}'")
SED_COMPOSER_JSON_CMD=$(printf 's/"version": "[0-9]*\.[0-9]*\.[0-9]*"/"version": "%s"/' "${VERSION}")

# Update the version in the CommunicatorConfiguration class
sed -i '' "$SED_COMMUNICATOR_CONFIG_CMD" $COMMUNICATOR_CONFIG_CLASS_PATH
# Update the version in the composer.json file
sed -i '' "$SED_COMPOSER_JSON_CMD" $COMPOSER_JSON_PATH

git add "$COMMUNICATOR_CONFIG_CLASS_PATH" "$COMPOSER_JSON_PATH"
git commit -m "Update version to $VERSION"
git tag -a $TAG -m "Release version $VERSION"

echo "Version updated to $VERSION and tagged in Git."
echo ""
echo "If this was a mistake, you can run"
echo " git reset --soft HEAD~1"
echo " git tag -d ${TAG}"

0 comments on commit 5044dad

Please sign in to comment.