Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cd #9

Merged
merged 5 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 44 additions & 30 deletions .github/workflows/release_sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
inputs:
release_version:
type: choice
description: 'The version to release will default to patch if not provided'
description: 'Select the version type to release'
required: true
default: patch
options:
Expand All @@ -23,50 +23,64 @@ jobs:
uses: ./.github/workflows/ci.yml

bump-version:
runs-on: ubuntu-latest
needs: release
steps:
- name: Mark Git directory as Safe
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"

- name: Bump version
id: bump_version
run: |
if [[ "${{ github.event.inputs.version_override }}" == beta || "${{ github.event.inputs.version_override }}" == alpha ]]; then
main_version="${current_version%-*}"
prerelease_version="${current_version#*-}"
# Define function to parse and bump version number
bump_version() {
if [[ "$1" == "beta" || "$1" == "alpha" ]]; then
main_version="${current_version%-*}"
prerelease_version="${current_version#*-}"
prerelease_identifier="${prerelease_version%[0-9]*}"
numeric_part="${prerelease_version#$prerelease_identifier}"
numeric_part=$(printf "%01d" $((10#$numeric_part + 1)))
echo "${main_version}-${prerelease_identifier}${numeric_part}"
else
echo "$1"
fi
}

# Fetch current version and determine new version
current_version=$(node -p "require('./package.json').version")
new_version=$(bump_version "${{ github.event.inputs.release_version }}")

# Bump package version and output new version
npm version "$new_version" --no-git-tag-version
echo "new_version=$new_version" >> $GITHUB_ENV
echo "new_branch=release/$new_version" >> $GITHUB_ENV

# Extract the prerelease identifier and the numeric part
prerelease_identifier="${prerelease_version%[0-9]*}"
numeric_part="${prerelease_version#$prerelease_identifier}"
echo "Version bumped to $new_version"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Increment the numeric part
numeric_part=$(printf "%01d" $((10#$numeric_part + 1)))
- name: Create Release Branch
run: |
new_branch=$new_version
git checkout -b $new_branch
git push origin $new_branch

# Construct the new version
new_version="${main_version}-${prerelease_identifier}${numeric_part}"
npm version $new_version
else
npm version "${{ github.event.inputs.version_override }}"
fi
version=$(node -p "require('./package.json').version")
echo "version=$version" >> $GITHUB_OUTPUT
- name: Create Tag and Release
run: |
new_tag="v$new_version"
git tag $new_tag
git push origin $new_tag
gh release create $new_tag --title "Release $new_tag" --notes "Release notes for $new_tag"

- name: Publish
- name: Publish Package
run: |
npm config set //registry.npmjs.org/:_authToken ${PUBLISH_TOKEN}
npm config set //registry.npmjs.org/:_authToken ${NODE_AUTH_TOKEN}
npm ci
npm run build
npm publish
env:
NPM_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}

- name: Push Tag
- name: Create Pull Request
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a "${tag}" -m "${message}"
git push origin "${tag}"
gh pr create --title "Merge release $new_version into main" --body "This is an automated pull request to update the version." --base main --head $new_branch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (personally, I think it's clearer, but up to you):

Suggested change
gh pr create --title "Merge release $new_version into main" --body "This is an automated pull request to update the version." --base main --head $new_branch
gh pr create --title "Bump version to $new_version" --body "This is an automated pull request to update the version." --base main --head $new_branch

env:
tag: v${{ needs.bump-version.outputs.version }}
message: Release v${{ needs.bump-version.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smileid/react-native",
"version": "10.0.0-beta00",
"name": "@smile_identity/react-native",
"version": "10.0.0-beta01",
"description": "Official wrapper for the Smile ID <v10 android and iOS SDKs",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
Loading