Update release.yml #57
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: Test Suite | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
name: 'Release' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
run: | | |
echo "::set-output name=dir::$(npm config get cache)" | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Setup npm Cache | |
uses: actions/cache@v4 | |
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' | |
with: | |
path: ${{ steps.npm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install Dependencies | |
if: steps.npm-cache.outputs.cache-hit != 'true' | |
run: | | |
npm install | |
- name: Setup Docker Cache | |
uses: actions/cache@v4 | |
id: docker-cache | |
with: | |
path: docker-cache | |
key: ${{ runner.os }}-docker-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-docker- | |
- name: Load Cached Docker Layers | |
run: | | |
if [ -d "docker-cache" ]; then | |
cat docker-cache/x* > my-image.tar | |
docker load < my-image.tar | |
rm -rf docker-cache | |
fi | |
- name: Build & Test | |
if: success() | |
run: | | |
npm test | |
- name: Tag | |
id: autotagger | |
if: success() | |
uses: butlerlogic/action-autotag@master | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
# If the new version/tag is a pre-release (i.e. 1.0.0-beta.1), create | |
# an environment variable indicating it is a prerelease. | |
- name: Pre-release | |
if: steps.autotagger.outputs.tagname != '' | |
run: | | |
if [[ "${{ steps.autotagger.output.version }}" == *"-"* ]]; then echo "::set-env IS_PRERELEASE=true";else echo "::set-env IS_PRERELEASE=''";fi | |
- name: Release | |
id: create_release | |
if: steps.autotagger.outputs.tagname != '' | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.autotagger.outputs.tagname }} | |
body: ${{ steps.autotagger.outputs.tagmessage }} | |
draft: false | |
prerelease: env.IS_PRERELEASE != '' | |
# Build tarballs of the module code. | |
- name: Build Release Artifacts | |
id: build_release | |
if: steps.create_release.outputs.id != '' | |
run: | | |
npm run bundle:module | |
ls -l ./.dist | |
# Upload tarballs to the release. | |
- name: Upload Release Artifacts | |
uses: AButler/[email protected] | |
if: steps.create_release.outputs.id != '' | |
with: | |
files: './.dist/*.tar.gz' | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
release-tag: ${{ steps.autotagger.outputs.tagname }} | |
- name: Publish to npm | |
id: publish_npm | |
if: steps.autotagger.outputs.tagname != '' | |
uses: author/action-publish@master | |
with: | |
scan: ./.dist | |
prerelease_dist_tag: next | |
env: | |
REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} | |
- name: Rollback Release | |
if: failure() && steps.create_release.outputs.id != '' | |
uses: author/action-rollback@master | |
with: | |
tag: ${{ steps.autotagger.outputs.tagname }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |