Skip to content

Merge pull request #6840 from wso2/changeset-release/master #2525

Merge pull request #6840 from wso2/changeset-release/master

Merge pull request #6840 from wso2/changeset-release/master #2525

# -------------------------------------------------------------------------------------
#
# Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com).
#
# WSO2 LLC. 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.
#
# --------------------------------------------------------------------------------------
name: πŸš€ Release
on:
push:
branches: [ master ]
paths-ignore:
- "LICENSE"
workflow_dispatch:
env:
GH_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
SHOULD_GENERATE_CHANGESET: 'true'
BRANCH: master
IS_HOTFIX: 'false'
BOT_USERNAME: ${{ secrets.RELEASE_BOT_USER_NAME }}
BOT_EMAIL: ${{ secrets.RELEASE_BOT_EMAIL }}
jobs:
release:
name: πŸš€ Release
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [lts/*]
maven-version: [3.8.6]
java-version: [11]
pnpm-version: [8.7.4]
steps:
- name: ⬇️ Checkout
id: checkout
uses: actions/[email protected]
with:
token: ${{ env.GH_TOKEN }}
fetch-depth: 0
- name: Set up Git user
run: |
git config user.name ${{ env.BOT_USERNAME }}}
git config user.email ${{ env.BOT_EMAIL }}}
- name: 🟒 Setup node
id: setup-node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: β˜• Set up JDK 11
id: jdk-setup
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: "adopt"
cache: maven
- name: 🦩 Set up Maven
uses: stCarolas/setup-maven@v4
id: mvn-setup
with:
maven-version: ${{ matrix.maven-version }}
- name: πŸ₯‘ Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ matrix.pnpm-version }}
run_install: false
- name: 🎈 Get pnpm store directory
id: get-pnpm-cache-dir
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- name: πŸ”† Cache pnpm modules
uses: actions/cache@v3
id: pnpm-cache
with:
path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: 🧩 Install Dependencies
id: install-dependencies
run: pnpm install
- name: πŸ“ Create settings.xml with Nexus credentials in ~/.m2
run: |
echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>nexus-releases</id>
<username>${{ secrets.NEXUS_USERNAME }}</username>
<password>${{ secrets.NEXUS_PASSWORD }}</password>
</server>
<server>
<id>wso2.releases</id>
<username>${{ secrets.NEXUS_USERNAME }}</username>
<password>${{ secrets.NEXUS_PASSWORD }}</password>
</server>
<server>
<id>wso2.snapshots</id>
<username>${{ secrets.NEXUS_USERNAME }}</username>
<password>${{ secrets.NEXUS_PASSWORD }}</password>
</server>
</servers>
<profiles>
<profile>
<id>include-sources</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</settings>' > ~/.m2/settings.xml
- name: πŸ’Ύ Cache local Maven repository
id: cache-maven-m2
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: πŸ“£ Create Release Pull Request or Publish to npm
if: ${{ env.SHOULD_GENERATE_CHANGESET == 'true' }}
id: changesets
uses: changesets/action@v1
with:
title: "[Release] [GitHub Action] Update package versions"
publish: pnpm publish:packages
version: pnpm version:packages
commit: "[WSO2 Release] [GitHub Action] [Release] [skip ci] update package versions"
env:
GITHUB_TOKEN: ${{ env.GH_TOKEN }}
- name: πŸ‘· Build Project
if: ${{ env.IS_HOTFIX == 'true' }}
id: build-project
run: pnpm build
- name: πŸš€ Perform Release
id: perform-release
working-directory: .github/workflows
run: |
PACKAGES="${{ toJson(steps.changesets.outputs.publishedPackages) }}"
bash ./scripts/release.sh "$PACKAGES" ${{ github.run_number }} ${{ env.IS_HOTFIX }}