-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add github workflow to build and publish (#14)
- Loading branch information
Showing
1 changed file
with
62 additions
and
19 deletions.
There are no files selected for viewing
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
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 }} |