Merge pull request #276 from adibmbrk/fix-release-action #109
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2020-2025, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | |
# | |
# WSO2 Inc. licenses this file to you under the Apache License, | |
# Version 2.0 (the "License"); you may not use this file except | |
# in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, | |
# software distributed under the License is distributed on an | |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
# KIND, either express or implied. See the License for the | |
# specific language governing permissions and limitations | |
# under the License. | |
# This is a basic workflow to help you get started with Actions | |
name: Release | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push for the main branch. | |
push: | |
branches: [ main ] | |
paths-ignore: | |
- "LICENSE" | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
Type: | |
description: 'Choose which version to bump before release' | |
required: true | |
default: 'patch' | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{secrets.ASGARDIO_GITHUB_BOT_TOKEN}} | |
if: github.repository == 'asgardeo/asgardeo-auth-react-sdk' | |
- uses: actions/checkout@v2 | |
if: github.repository != 'asgardeo/asgardeo-auth-react-sdk' | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Build | |
run: | | |
yarn build | |
- name: Setup Git User | |
run: | | |
git config --global user.email "version.bump@github.action.com" | |
git config --global user.name "asgardeo-github-bot" | |
- name: Create Release Pull Request or Publish | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
publish: yarn publish:packages | |
version: yarn version:packages | |
commit: "[Asgardeo Release] [GitHub Actions] Update package versions" | |
title: "[Release] [GitHub Action] Update package versions" | |
env: | |
GITHUB_TOKEN: ${{ secrets.ASGARDIO_GITHUB_BOT_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Pack Release Artifacts | |
if: steps.changesets.outputs.hasChangesets == 'false' | |
run: | | |
mkdir artifacts | |
if test -d samples | |
then | |
cd samples | |
rm -rf **/node_modules/ | |
rm -rf samples/**/dist/ | |
rm -rf samples/asgardeo-choreo-react-express/apps/**/node_modules/ | |
rm -rf samples/asgardeo-choreo-react-express/apps/client/build/ | |
rm -rf samples/asgardeo-choreo-react-express/apps/server/dist/ | |
for dir in */ ; do | |
zip -r "../artifacts/${dir%/}.zip" $dir | |
done | |
fi | |
- name: Release Asgardeo Auth React SDK | |
if: steps.changesets.outputs.hasChangesets == 'false' | |
run: | | |
version=`git describe --tags --abbrev=0` | |
echo ${{secrets.ASGARDIO_GITHUB_BOT_TOKEN}} | gh auth login --with-token | |
if test -d samples | |
then | |
gh release create $version artifacts/* | |
else | |
gh release create $version | |
fi |