Skip to content

Commit

Permalink
feat: use semantic-release
Browse files Browse the repository at this point in the history
  • Loading branch information
HashMapsData2Value committed May 22, 2024
1 parent efb4e61 commit 81cd2ff
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
26 changes: 11 additions & 15 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Build and Release

on:
push:
tags:
- "v*.*.*"
branches:
- "release/v*"

jobs:
build:
Expand Down Expand Up @@ -35,22 +35,18 @@ jobs:
id: get_version_jvm
run: echo ::set-output name=VERSION_JVM::$(grep "version =" jvmModule/build.gradle.kts | awk -F\" '{print $2}')

- name: Get tag name
id: get_tag
run: echo ::set-output name=TAG_NAME::${GITHUB_REF/refs\/tags\/v/}
- name: Get branch name
id: get_branch
run: echo ::set-output name=BRANCH_NAME::${GITHUB_REF#refs/heads/release/v}

- name: Check versions
run: |
if [ "${{ steps.get_version_android.outputs.VERSION_ANDROID }}" != "${{ steps.get_tag.outputs.TAG_NAME }}" ] || [ "${{ steps.get_version_jvm.outputs.VERSION_JVM }}" != "${{ steps.get_tag.outputs.TAG_NAME }}" ]; then
echo "Version mismatch. Make sure the versions in androidModule/build.gradle and jvmModule/build.gradle.kts match the tag name."
if [ "${{ steps.get_version_android.outputs.VERSION_ANDROID }}" != "${{ steps.get_branch.outputs.BRANCH_NAME }}" ] || [ "${{ steps.get_version_jvm.outputs.VERSION_JVM }}" != "${{ steps.get_branch.outputs.BRANCH_NAME }}" ]; then
echo "Version mismatch. Make sure the versions in androidModule/build.gradle and jvmModule/build.gradle.kts match the branch name."
exit 1
fi
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
fail_on_unmatched_files: true
files: |
./build/Bip32Ed25519-JVM-*.jar
./build/Bip32Ed25519-Android-*-release.aar
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"branches": ["release/v*"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/github",
{
"assets": [
{ "path": "./build/Bip32Ed25519-JVM-*.jar", "label": "JVM Library" },
{ "path": "./build/Bip32Ed25519-Android-*-release.aar", "label": "Android Library" }
]
}
],
"@semantic-release/git"
]
}
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,9 @@ Github Workflows are used. `./initialize.sh`is called, which attempts to build t

This project follows [Semantic Versioning](https://semver.org) guidelines.

To create a new release, it is possible to create one directly through the GitHub interface.
To create a new release, branch off of `main` into a release branch, e.g. `release/v.1.0.0`

However, it is instead recommended to create a tag locally:

```bash
git tag -a v0.1.0 "Annotation"
```

This creates an annotated tag for version v0.1.0.

```bash
git push origin v0.1.0
```

This will push v0.1.0 to the repo, triggering a Github Workflow which produces a Release at that tag.
This will push v1.0.0 to the repo, triggering a Github Workflow which creates a Tag and a Release at that tag.

Note that the action will check that the version tag matches the `version` field in `jvmModule/build.gradle.kts` and the `versionName`field in `androidModule/build.gradle`. Otherwise it will fail and no release will be made.

Expand Down

0 comments on commit 81cd2ff

Please sign in to comment.