Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update release workflow to work with npm + not use auto #4

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 56 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out code repository source code
uses: actions/checkout@v3

- id: setup-node
name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Check out code repository source code
uses: actions/checkout@v3

- name: Install dependencies
run: npm ci

Expand All @@ -29,23 +29,65 @@ jobs:

# Publishing is done in a separate job to allow
# for all matrix builds to complete.
BuildRelease:
release:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
name: Checkout Code
steps:
- name: Check out repo
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Build and Release
uses: jupiterone/action-npm-build-release@v1

- name: Check out repo
uses: actions/checkout@v3
with:
fetch-depth: 2

# Fetch tags and describe the commit before the merge commit
# to see if it's a version publish
- name: Fetch tags
run: |
git fetch --tags
if git describe --exact-match --match "v*.*.*" HEAD^2
then
echo "Found version commit tag. Publishing."
echo "publish=true" >> $GITHUB_ENV
echo "VERSION_NUM=`echo $(git describe --tags --abbrev=0 | sed -e "s/v//gI")`" >> $GITHUB_ENV
else
echo "Version commit tag not found. Not publishing."
fi

- name: Publish
if: env.publish == 'true'
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > .npmrc
npm ci
npm run build
npm publish

- name: Get Version Changelog Entry
if: env.publish == 'true'
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
version: ${{ env.VERSION_NUM }}
path: ./CHANGELOG.md
continue-on-error: true

- name: Create Release
if: env.publish == 'true'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
npm_auth_token: ${{ secrets.NPM_AUTH_TOKEN }}
gh_token: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }}
tag_name: ${{ steps.changelog_reader.outputs.version }}
release_name: Release ${{ steps.changelog_reader.outputs.version }}
body: ${{ steps.changelog_reader.outputs.changes }}
prerelease:
${{ steps.changelog_reader.outputs.status == 'prereleased' }}
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
continue-on-error: true
Loading