Skip to content

Commit

Permalink
chore: update release process and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ehrdi committed Aug 19, 2024
1 parent a38611f commit 5f01de9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 130 deletions.
92 changes: 20 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ Welcome to the PAYONE Commerce Platform Client JavaScript SDK for the PAYONE Com
- [PAYONE Commerce Platform Compliant Interfaces](#payone-commerce-platform-compliant-interfaces)
- [Demonstration Projects](#demonstration-projects)
- [Contributing](#contributing)
- [Releasing](#releasing)
- [How to use the prepare_release.sh script](#how-to-use-the-prepare_releasesh-script)
- [Releasing the library](#releasing-the-library)
- [Preparing the Release](#preparing-the-release)
- [Changelog Generation with Conventional Changelog](#changelog-generation-with-conventional-changelog)
- [Merging the Release Branch](#merging-the-release-branch)
- [GitHub Action for Release](#github-action-for-release)
- [Minimum Supported Browser Versions](#minimum-supported-browser-versions)
- [License](#license)
Expand Down Expand Up @@ -683,63 +684,26 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md)

**[back to top](#table-of-contents)**

## Releasing
## Releasing the library

To ensure a smooth release process, a pre-release script has been created. This script automates versioning, tagging, and ensuring the working directory is in a proper state before creating a new release. Each release requires creating a new release branch, applying changes there, and verifying the version against the release branch name.
### Preparing the Release

### `prepare_release.sh` Script
- Checkout develop branch
- Create release branch (release/0.1.0)

The [`prepare_release.sh`](./prepare_release.sh) script is a bash script designed to update the version number in your project, commit the changes, and tag the commit with the new version number.

### How to use the `prepare_release.sh` Script

1. **Create and switch to a new release branch**:

- Create a release branch named `release/v<version>`.
- Example:
```sh
git checkout -b release/v1.2.3
```

2. **Ensure your working directory is clean**:

- Make sure you have no uncommitted changes. The script will exit if there are any changes detected.
- Verify that you are on the `release/v<version>` branch before proceeding.

3. **Run the script with the desired version number**:

- Open your terminal and navigate to the root directory of your project.
- Execute the script with the version number as an argument.

```sh
./prepare_release.sh <version>
```

- Example:

```sh
./prepare_release.sh 1.2.3
```

4. **Script Workflow**:
```sh
git checkout -b release/0.1.0
```

- The script checks if a version number is provided and validates its format.
- It ensures the working directory is clean and that you are on the `release/v<version>` branch.
- It verifies that the provided version tag matches the release branch name.
- It updates the version number in `package.json` and `package-lock.json`.
- Commits the changes with a message "Update version to <version>".
- Tags the commit with "v<version>".
- Apply versioning

5. **Handling Mistakes**:
- If you make a mistake, you can undo the commit and delete the tag by running the following commands:
```sh
git reset --soft HEAD~1
git tag -d v<version>
```
```sh
npm version major|minor|patch
```

### Changelog Generation with Conventional Changelog

After calling the `prepare_release.sh` script, it is recommended to manually trigger the changelog generation script (which uses [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog)).
The changelog gets generated automatically when the npm version gets bumped via `npm version major|minor|patch` within the `version.sh` script.

1. **Conventional Commit Messages**:

Expand All @@ -751,32 +715,14 @@ After calling the `prepare_release.sh` script, it is recommended to manually tri
- We enforce conventional commit messages using [Lefthook](https://github.com/evilmartians/lefthook) with [commitlint](https://github.com/conventional-changelog/commitlint).
- This setup ensures that all commit messages are validated before they are committed.

3. **Generate Changelog**:
- Run the changelog generation script to update the `CHANGELOG.md` file:
```sh
npm run changelog
```
- Review and commit the updated changelog before proceeding with the release.

### Merging the Release Branch

1. **Open a Pull Request (PR)**:

- Open a PR from the `release/v<version>` branch to the `master` branch on GitHub.
- Include a clear description of the changes and the new version.

2. **Code Review**:

- Request reviews from team members.
- Address feedback and make necessary changes.

3. **Merge PR**:

- Once approved, merge the PR to `master`.
- Create PR on `develop` branch
- Merge `develop` in `master` branch

### GitHub Action for Release

After successfully running the `prepare_release.sh` and changelog generation scripts and committing all changes to the `master` branch via a PR, an admin can trigger a GitHub Action to finalize and publish the release. This action ensures that the release process is automated, consistent, and deploys the new release from the `master` branch.
After successfully merging all changes to the `master` branch, an admin can trigger a GitHub Action to finalize and publish the release. This action ensures that the release process is automated, consistent, and deploys the new release from the `master` branch.

**Triggering the GitHub Action**:

Expand All @@ -786,6 +732,8 @@ After successfully running the `prepare_release.sh` and changelog generation scr

By following these steps, you can efficiently manage and streamline the release process for the PAYONE Commerce Platform Client JavaScript SDK, ensuring that the new release is published from the `master` branch while maintaining consistency and reliability.

**[back to top](#table-of-contents)**

## Minimum Supported Browser Versions

The PAYONE Commerce Platform Client JavaScript SDK targets ES6 (ECMAScript 2015) and supports the following minimum browser versions:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"prepack": "npm run lint && npm run prepublishOnly",
"test": "vitest",
"test:coverage": "vitest run --coverage",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"version": "./version.sh"
},
"keywords": [
"payone",
Expand Down
57 changes: 0 additions & 57 deletions prepare_release.sh

This file was deleted.

10 changes: 10 additions & 0 deletions version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
NEW_VERSION=$npm_package_version

if [ -n "$NEW_VERSION" ]; then
npm run changelog
git add CHANGELOG.md
echo "Updated CHANGELOG.md"

else
echo "Script can only be run as npm version hook"
fi

0 comments on commit 5f01de9

Please sign in to comment.