v3.53.0 #23
Workflow file for this run
This file contains hidden or 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: Release | |
on: | |
# This job runs when a new release is published | |
release: | |
types: [published] | |
jobs: | |
prePublishPackageTest: | |
name: Prepublish package test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Retrieve dependencies from cache | |
uses: actions/cache@v4 | |
id: cacheNpm | |
with: | |
path: | | |
~/.npm | |
node_modules | |
key: npm-v22-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} | |
- name: Install Node.js and npm | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
registry-url: https://registry.npmjs.org | |
- name: Install dependencies | |
if: steps.cacheNpm.outputs.cache-hit != 'true' | |
run: | | |
npm update --no-save | |
npm update --save-dev --no-save | |
# Store the name of the release | |
# See https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions | |
- run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- run: npm version $RELEASE_VERSION --no-git-tag-version | |
- name: Build local package | |
run: npm pack | |
- name: Run tests against version packaged with npm pack | |
run: | | |
TEMP_ARRAY=($(echo $GITHUB_REF | tr "/" "\n")) | |
TAG=${TEMP_ARRAY[@]: -1} | |
PACKAGE_VERSION=${TAG:1} | |
mkdir "serverless-${PACKAGE_VERSION}" | |
tar zxf "osls-${PACKAGE_VERSION}.tgz" -C "serverless-${PACKAGE_VERSION}" | |
cp -R test "serverless-${PACKAGE_VERSION}/package" | |
ln -s "$(pwd)"/node_modules "serverless-${PACKAGE_VERSION}/package/node_modules" | |
cd "serverless-${PACKAGE_VERSION}/package" | |
script -e -c "npm test -- -b" | |
npmPublish: | |
name: Publish to NPM | |
needs: prePublishPackageTest | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Retrieve dependencies from cache | |
uses: actions/cache@v4 | |
id: cacheNpm | |
with: | |
path: | | |
~/.npm | |
node_modules | |
key: npm-v22-${{ runner.os }}-refs/heads/main-${{ hashFiles('package.json') }} | |
- name: Install Node.js and npm | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
registry-url: https://registry.npmjs.org | |
# Normally we have a guarantee that deps are already there, still it may not be the case when: | |
# - `main` build for same commit failed (and we still pushed tag manually) | |
# - We've pushed tag manually before `main` build finalized | |
- name: Install dependencies | |
if: steps.cacheNpm.outputs.cache-hit != 'true' | |
run: | | |
npm update --no-save | |
npm update --save-dev --no-save | |
# Store the name of the release | |
# See https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions | |
- run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- run: npm version $RELEASE_VERSION --no-git-tag-version | |
- name: Publish new version | |
# Note: Setting NODE_AUTH_TOKEN as job|workspace wide env var won't work | |
# as it appears actions/setup-node sets own value | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npm publish --access public --tag=latest |