Skip to content

Commit

Permalink
fix: workflow to publish and generate release
Browse files Browse the repository at this point in the history
  • Loading branch information
Minozzzi committed Mar 20, 2024
1 parent b9076af commit 17ea560
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 43 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create Release

on:
push:
tags:
- v*

permissions:
contents: write

jobs:
release:
name: Release pushed tag

runs-on: ubuntu-latest

steps:
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \
--generate-notes
--draft
- name: Login to npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc

- name: Publish Configuration to NPM
run: npm publish --verbose --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48 changes: 5 additions & 43 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,19 @@
name: Publish Configurations on Release

on:
push:
branches:
- main
release:
types:
- "released"

permissions:
contents: write

jobs:
publish:
release:
name: Publish to NPM
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: npm install

- uses: actions/cache@v3
name: Setup npm cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Tag Name
id: set_tag
run: |
echo ::set-output name=tag::$(git describe HEAD --abbrev=0)
echo "Tag: ${{ steps.set_tag.outputs.tag }}"
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_name: Release ${{ steps.tag.outputs.tag }}
tag_name: ${{ steps.tag.outputs.tag }}
body_path: CHANGELOG.md
draft: false
prerelease: false

- name: Login to npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc

Expand Down

0 comments on commit 17ea560

Please sign in to comment.