Skip to content

Release

Release #16

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
branch:
description: The branch to release from
required: true
default: master
release-type:
description: The type of release to perform
required: true
default: GA
type: choice
options:
- GA
- RC
- Beta
jobs:
validate:
runs-on: ubuntu-latest
name: Validate input parameters
outputs:
vtag: ${{ steps.vtag.outputs.vtag }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
- name: Create version tag
id: vtag
run: |
PACKAGE_VERSION=$(sed -n 's/^ *"version": *"//p' package.json | tr -d '"' | tr -d ',' | tr -d '[[:space:]]')
VTAG="${PACKAGE_VERSION}.${{ github.event.inputs.release-type }}"
echo "vtag=${VTAG}" >> $GITHUB_ENV
echo "vtag=${VTAG}" >> $GITHUB_OUTPUT
- name: Validate version
uses: actions/github-script@v6
env:
vtag: ${{ env.vtag }}
with:
script: |
const releaseMeta = github.rest.repos.listReleases.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
});
const releases = await github.paginate(releaseMeta);
for (const release of releases) {
if (release.name === process.env.vtag) {
throw new Error(`${process.env.vtag} already exists`);
}
}
console.log(`${process.env.vtag} does not exist so continuing`)
android:
runs-on: ubuntu-20.04
needs: [validate]
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
USE_CCACHE: 1
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
- name: Android build
uses: ./.github/actions/build-android
with:
node-version: '16.x'
java-version: '11'
ios:
runs-on: macos-13
name: iOS
needs: [validate]
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
USE_CCACHE: 1
DEVELOPER_DIR: /Applications/Xcode_14.3.app/Contents/Developer
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
- name: iOS build
uses: ./.github/actions/build-ios
with:
node-version: '16.x'
package:
runs-on: macos-12
name: Package
env:
SDK_BUILD_CACHE_DIR: ${{ github.workspace }}/.native-modules
DEVELOPER_DIR: /Applications/Xcode_14.2.app/Contents/Developer
vtag: ${{ needs.validate.outputs.vtag }}
needs: [validate, android, ios]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
- name: Package
uses: ./.github/actions/package
with:
node-version: '16.x'
java-version: '11'
vtag: ${{ env.vtag }}
release:
runs-on: ubuntu-latest
name: Release
environment: Release
needs: [validate, package]
env:
vtag: ${{ needs.validate.outputs.vtag }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
- run: echo ${{ env.vtag }}
- name: Download Linux artifact
uses: actions/download-artifact@v3
with:
name: mobilesdk-${{ env.vtag }}-linux
- name: Download MacOS artifact
uses: actions/download-artifact@v3
with:
name: mobilesdk-${{ env.vtag }}-osx
- name: Download Windows artifact
uses: actions/download-artifact@v3
with:
name: mobilesdk-${{ env.vtag }}-win32
- name: Create and push tag
run: |
TAG_VERSION=$( echo ${{ env.vtag }} | tr '.' '_' )
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag "${TAG_VERSION}"
git push origin "${TAG_VERSION}"
echo "clean-tag=${TAG_VERSION}" >> $GITHUB_ENV
- name: Upload SDK zips (GA)
uses: softprops/action-gh-release@v1
if: ${{ github.event.inputs.release-type == 'GA' }}
with:
files: mobilesdk-${{ env.vtag }}-*
tag_name: ${{ env.clean-tag }}
name: ${{ env.vtag }}
- name: Upload SDK zips (non-GA)
uses: softprops/action-gh-release@v1
if: ${{ github.event.inputs.release-type != 'GA' }}
with:
files: mobilesdk-${{ env.vtag }}-*
tag_name: ${{ env.clean-tag }}
name: ${{ env.vtag }}
prerelease: true
- name: Bump version
if: ${{ github.event.inputs.release-type == 'GA' }}
run: |
npm version patch --no-git-tag-version
git add package.json
git add package-lock.json
git commit -m "chore(release): bump version"
git push