Skip to content

Commit

Permalink
feat: add github workflow to build and publish (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
paciops authored Jan 31, 2025
1 parent 3ead1ba commit ca9cc32
Showing 1 changed file with 62 additions and 19 deletions.
81 changes: 62 additions & 19 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,68 @@
name: Publish package to GitHub Packages
name: Create New Version

on:
push:
branches:
- main
workflow_dispatch:
inputs:
version_type:
description: 'Version type (patch/minor/major)'
required: true
type: choice
options:
- patch
- minor
- major

jobs:
build:
create_version:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout code
uses: actions/checkout@v4
with:
node-version: '22.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@infinitaslearning'
- run: npm ci
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "Infinitas Learning"
- run: npm version `npm pkg get version | tr -d '"' | cut -d '.' -f 1-2`.${{ github.run_number }}
- run: npm publish
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Set up Git
run: |
git config user.name "Infinitas Learning"
git config user.email "[email protected]"
- name: Get current version
id: current_version
run: echo "version=$(npm version --json | jq -r '."@infinitaslearning/systemic-express"')" >> $GITHUB_OUTPUT

- name: Bump version
id: bump_version
run: |
version_type=${{ github.event.inputs.version_type }}
new_version=$(npm version $version_type --no-git-tag-version)
echo "new_version=$new_version" >> $GITHUB_OUTPUT
- name: Update package.json
run: |
git add package.json
git commit -m "Bump version to ${{ steps.bump_version.outputs.new_version }}"
- name: Create and push tag
run: |
git tag ${{ steps.bump_version.outputs.new_version }}
git push origin HEAD:main --tags
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.bump_version.outputs.new_version }}
release_name: Release ${{ steps.bump_version.outputs.new_version }}
draft: false
prerelease: false

- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit ca9cc32

Please sign in to comment.