Skip to content

Commit

Permalink
Separated release workflow from testing and building
Browse files Browse the repository at this point in the history
  • Loading branch information
JUGG097 committed Jun 28, 2023
1 parent 045359b commit a38e8c5
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 22 deletions.
23 changes: 2 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test, Build and Release
name: Test, Build

on:
# Triggers the workflow on push or pull request events but only for the main branch
Expand Down Expand Up @@ -29,23 +29,4 @@ jobs:
run: npm run build

# https://github.com/marketplace/actions/automated-releases-for-npm-packages
release:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
needs: ["test_build"]
steps:
- uses: actions/checkout@v3
- uses: mikeal/merge-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# - uses: actions/checkout@v3
# # Setup .npmrc file to publish to npm
# - uses: actions/setup-node@v3
# with:
# node-version: "16.x"
# registry-url: "https://registry.npmjs.org"
# - run: npm ci
# - run: npm publish --access public
# env:
# NODE_AUTH_TOKEN:

64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: release
on:
release:
types: [created]
jobs:
release:
runs-on: ubuntu-latest
steps:
# Checkout the exact commit tagged on the release.
- name: Checkout repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.target_commitish }}

# This is the action in this repo! 👇
# Note we set an `id` called `release`. We'll use that later...
- name: Validate and extract release information
id: release
uses: manovotny/github-releases-for-automated-package-publishing-action@v2.0.1

# When setting the node version for publishing a release, it's also impotant
# to set `always-auth` and `registry-url` too. I've encountered vauge errors
# and publishing doesn't work unless they are supplied.
#
# This example is using NPM's registry. If you were publishing to GitHub's
# Package registry, you'd use `https://npm.pkg.github.com` instead.
- name: Set node version
uses: actions/setup-node@v3
with:
always-auth: true
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'

# Perform installs, run tests, run a build step, etc. here, as needed.

# The last two steps will publish the package. Note that we're using
# information from the `release` step above (I told you we'd use it
# later). Notice the `if` statements on both steps...
#
# If there *is* a tag (ie. `beta`, `canary`, etc.), we publish a
# "pre-release" or "tagged" version of a package (ie. 1.2.3-beta.1).
#
# If there *is not* a tag (ie. `beta`, `canary`, etc.), we publish a
# version of a package (ie. 1.2.3).
#
# This example is using npm to publish, but you could just as easily
# use yarn, if you prefer. It's also publishing to the NPM registry,
# thus, it's using `NPM_TOKEN`, but you could just as easily use
# `GITHUB_TOKEN` if you were publishing to the GitHub Package registry.

# This will publish a "pre-release" or "tagged" version of a package.

# This will publish a version of a package.
- name: Publish version
if: steps.release.outputs.tag == ''
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish tagged version
if: steps.release.outputs.tag != ''
run: npm publish --tag ${{ steps.release.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "retrievetokens",
"version": "1.0.0",
"version": "1.0.1",
"description": "A simple package for interacting with web client storages like `localStorage`",
"source": "src/index.ts",
"exports": {
Expand Down

0 comments on commit a38e8c5

Please sign in to comment.