ALL-2835 - Extension Ecosystem enabler (#933) #2194
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
name: Build | |
on: | |
push: | |
env: | |
SDK_ERROR_MESSAGES_VERSION: "master" | |
V4_API_KEY_MAINNET: ${{ secrets.V4_API_KEY_MAINNET }} | |
V3_API_KEY_MAINNET: ${{ secrets.V3_API_KEY_MAINNET }} | |
V3_API_KEY_TESTNET: ${{ secrets.V3_API_KEY_TESTNET }} | |
NON_TATUM_RPC_ETH_URL: ${{ secrets.NON_TATUM_RPC_ETH_URL }} | |
VERBOSE: ${{ secrets.verbose }} | |
jobs: | |
metadata: | |
runs-on: ubuntu-latest | |
outputs: | |
current_branch: ${{ steps.branch-name.outputs.current_branch }} | |
package_version: ${{ env.package_version }} | |
release_exists: ${{ env.release_exists }} | |
release_prerelease: ${{ steps.semver-utils.outputs.prerelease }} | |
package_tag: ${{ env.package_tag }} | |
steps: | |
- name: Get branch name | |
id: branch-name | |
uses: tj-actions/branch-names@v6 | |
- uses: actions/checkout@v3 | |
- name: Get package version | |
id: package-version | |
run: | | |
version=$(jq -r '.version' package.json) | |
echo "package_version=$version" >> "$GITHUB_ENV" | |
- name: Check if release for package version already exists | |
id: release-exists | |
run: | | |
curl --fail --silent --max-time 5 "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${{ env.package_version }}" && echo "release_exists=true" >> $GITHUB_ENV || echo "release_exists=false" >> $GITHUB_ENV | |
- name: Get semver data | |
uses: madhead/semver-utils@v3 | |
id: semver-utils | |
with: | |
lenient: false | |
version: ${{ env.package_version }} | |
- name: NPM release tag | |
id: npm-release-tag | |
run: | | |
[[ "${{ steps.semver-utils.outputs.prerelease }}" == "" ]] && echo "package_tag=latest" >> $GITHUB_ENV || echo "package_tag=${{ env.package_version }}" >> $GITHUB_ENV | |
build: | |
runs-on: ubuntu-latest | |
needs: [metadata] | |
strategy: | |
fail-fast: false | |
matrix: | |
nodejs: [ 18 ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download SDK error messages | |
run: curl --fail --silent https://raw.githubusercontent.com/tatumio/tatum-sdk-error-mesages/$SDK_ERROR_MESSAGES_VERSION/error-messages.json --output resources/error-messages.json | |
# https://github.com/actions/setup-node | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.nodejs }} | |
cache: 'yarn' | |
- run: yarn install | |
- run: yarn build-all | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-${{ matrix.nodejs }} | |
path: dist/ | |
retention-days: 7 | |
if: | | |
needs.metadata.outputs.current_branch == 'master' || | |
contains(github.event.head_commit.message, 'release prerelease') | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# https://github.com/actions/setup-node | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'yarn' | |
- run: yarn install | |
- run: yarn lint | |
- run: yarn test | |
env: | |
V4_API_KEY_MAINNET: ${{ secrets.V4_API_KEY_MAINNET }} | |
V3_API_KEY_MAINNET: ${{ secrets.V3_API_KEY_MAINNET }} | |
V3_API_KEY_TESTNET: ${{ secrets.V3_API_KEY_TESTNET }} | |
NON_TATUM_RPC_ETH_URL: ${{ secrets.NON_TATUM_RPC_ETH_URL }} | |
VERBOSE: ${{ secrets.verbose }} | |
release: | |
runs-on: ubuntu-latest | |
if: needs.metadata.outputs.current_branch == 'master' && needs.metadata.outputs.release_exists == 'false' | |
needs: [ metadata, build, test ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Git config | |
run: | | |
git config --local user.name github-actions | |
git config --local user.email [email protected] | |
- name: Get release notes | |
id: get_release_notes | |
uses: ffurrer2/extract-release-notes@v1 | |
# TAG the repo | |
- name: Create tag ${{needs.metadata.outputs.package_version}} | |
uses: rickstaa/action-create-tag@v1 | |
with: | |
tag: "${{needs.metadata.outputs.package_version}}" | |
- name: "Create a GitHub release ${{ needs.metadata.outputs.package_version }}" | |
# Create release using the tag above | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: "${{needs.metadata.outputs.package_version}}" | |
name: "${{needs.metadata.outputs.package_version}}" | |
body: | | |
${{ steps.get_release_notes.outputs.release_notes }} | |
npm: | |
runs-on: ubuntu-latest | |
if: | | |
(needs.metadata.outputs.current_branch == 'master' && needs.metadata.outputs.release_exists == 'false') || | |
(needs.metadata.outputs.current_branch != 'master' && needs.metadata.outputs.release_prerelease != '' && contains(github.event.head_commit.message, 'release prerelease')) | |
needs: [ metadata, build, test ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: build-18 | |
path: dist | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
registry-url: 'https://registry.npmjs.org' | |
- run: yarn publish --access public --tag ${{ needs.metadata.outputs.package_tag }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |