mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Rework release workflow (split npm and github release), and skip npm publish for prereleases
This commit is contained in:
parent
4e098bcff7
commit
66c1da0f1e
1 changed files with 54 additions and 32 deletions
86
.github/workflows/build-and-release.yml
vendored
86
.github/workflows/build-and-release.yml
vendored
|
|
@ -11,9 +11,11 @@ permissions:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
set-version:
|
set-version:
|
||||||
|
name: Set version number
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.get_version.outputs.tag }}
|
version: ${{ steps.get_version.outputs.tag }}
|
||||||
|
is_prerelease: ${{ steps.check_prerelease.outputs.is_prerelease }}
|
||||||
steps:
|
steps:
|
||||||
- name: Set version number
|
- name: Set version number
|
||||||
id: get_version
|
id: get_version
|
||||||
|
|
@ -21,13 +23,23 @@ jobs:
|
||||||
version="${{ github.ref_name }}"
|
version="${{ github.ref_name }}"
|
||||||
echo "tag=$version" >> $GITHUB_OUTPUT
|
echo "tag=$version" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Check if pre-release
|
||||||
|
id: check_prerelease
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
IS_PRERELEASE=$(gh release view ${{ steps.get_version.outputs.tag }} --json isPrerelease --jq '.isPrerelease')
|
||||||
|
echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
|
||||||
|
echo "Release ${{ steps.get_version.outputs.tag }} is pre-release: $IS_PRERELEASE"
|
||||||
|
|
||||||
create-binaries:
|
create-binaries:
|
||||||
needs: set-version
|
needs: set-version
|
||||||
uses: ./.github/workflows/create-artifact.yml
|
uses: ./.github/workflows/create-artifact.yml
|
||||||
with:
|
with:
|
||||||
version: ${{ needs.set-version.outputs.version }}
|
version: ${{ needs.set-version.outputs.version }}
|
||||||
|
|
||||||
build:
|
publish-binaries:
|
||||||
|
name: Publish to GitHub release
|
||||||
needs: [set-version, create-binaries]
|
needs: [set-version, create-binaries]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|
@ -35,37 +47,6 @@ jobs:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: "lts/*"
|
|
||||||
registry-url: "https://registry.npmjs.org/"
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
|
||||||
|
|
||||||
- name: Setup safe-chain
|
|
||||||
run: curl -fsSL https://github.com/AikidoSec/safe-chain/releases/latest/download/install-safe-chain.sh | sh -s -- --ci
|
|
||||||
|
|
||||||
- name: Set the version in safe-chain package
|
|
||||||
run: npm --no-git-tag-version version ${{ needs.set-version.outputs.version }} --workspace=packages/safe-chain
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: npm run test
|
|
||||||
|
|
||||||
- name: Copy documentation files to package
|
|
||||||
run: |
|
|
||||||
cp README.md packages/safe-chain/
|
|
||||||
cp LICENSE packages/safe-chain/
|
|
||||||
cp -r docs packages/safe-chain/
|
|
||||||
|
|
||||||
- name: Publish to npm
|
|
||||||
run: |
|
|
||||||
echo "Publishing version ${{ needs.set-version.outputs.version }} to NPM"
|
|
||||||
npm publish --workspace=packages/safe-chain --access public --provenance
|
|
||||||
|
|
||||||
- name: Download all binary artifacts
|
- name: Download all binary artifacts
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|
@ -107,3 +88,44 @@ jobs:
|
||||||
release-artifacts/install-safe-chain.ps1 \
|
release-artifacts/install-safe-chain.ps1 \
|
||||||
release-artifacts/uninstall-safe-chain.sh \
|
release-artifacts/uninstall-safe-chain.sh \
|
||||||
release-artifacts/uninstall-safe-chain.ps1
|
release-artifacts/uninstall-safe-chain.ps1
|
||||||
|
|
||||||
|
publish-npm:
|
||||||
|
name: Publish to npm
|
||||||
|
needs: [set-version, create-binaries]
|
||||||
|
if: needs.set-version.outputs.is_prerelease != 'true'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: "lts/*"
|
||||||
|
registry-url: "https://registry.npmjs.org/"
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||||
|
|
||||||
|
- name: Setup safe-chain
|
||||||
|
run: curl -fsSL https://github.com/AikidoSec/safe-chain/releases/latest/download/install-safe-chain.sh | sh -s -- --ci
|
||||||
|
|
||||||
|
- name: Set the version in safe-chain package
|
||||||
|
run: npm --no-git-tag-version version ${{ needs.set-version.outputs.version }} --workspace=packages/safe-chain
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: npm run test
|
||||||
|
|
||||||
|
- name: Copy documentation files to package
|
||||||
|
run: |
|
||||||
|
cp README.md packages/safe-chain/
|
||||||
|
cp LICENSE packages/safe-chain/
|
||||||
|
cp -r docs packages/safe-chain/
|
||||||
|
|
||||||
|
- name: Publish to npm
|
||||||
|
run: |
|
||||||
|
echo "Publishing version ${{ needs.set-version.outputs.version }} to NPM"
|
||||||
|
npm publish --workspace=packages/safe-chain --access public --provenance
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue