Skip to content

Backport the artifact build changes to release-1.1 #10

Backport the artifact build changes to release-1.1

Backport the artifact build changes to release-1.1 #10

name: Publish Artifacts
on:
pull_request:
types: [closed]
branches:
- release-v*
env:
FOUNDRY_PROFILE: ci
jobs:
publish-artifacts-to-npm:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org/'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable
- name: Configure Git for Foundry
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
- name: Configure NPM for Scoped Package
run: |
cd npm-artifacts
SCOPE=$(jq -r '.name' package.json | cut -d'/' -f1)
echo "$SCOPE:registry=https://registry.npmjs.org/" > ~/.npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
- name: Get Version from package.json
id: get_version
run: |
cd npm-artifacts
VERSION=$(jq -r '.version' package.json)
TAG_VERSION="v$VERSION"
echo "VERSION=$TAG_VERSION" >> $GITHUB_ENV
- name: Create Git Tag
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git tag $VERSION
git push origin $VERSION
- name: Install Dependencies
run: |
cd npm-artifacts
yarn install --frozen-lockfile --ignore-scripts
- name: Build Package
env:
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
run: |
cd npm-artifacts
yarn build
- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd npm-artifacts
if [[ "$VERSION" == *"-alpha"* ]]; then
npm publish --tag alpha --access public
else
npm publish --tag latest --access public
fi