Skip to content

Commit

Permalink
Merge pull request #23 from VictoriaShyika/release-and-npm-publish
Browse files Browse the repository at this point in the history
Release and npm publish
  • Loading branch information
VictoriaShyika authored Apr 23, 2024
2 parents 4c6ba34 + f444294 commit 7bda374
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 27 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/publish-npm-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish NPM Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
- run: npm ci

publish-npm:
needs: build
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
38 changes: 38 additions & 0 deletions .github/workflows/release-on-version-change.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Version Check and Release Creating

on:
push:
branches:
- main

jobs:
version-check:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.version.outputs.changed }}
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for Version Update
id: version
uses: EndBug/[email protected]
with:
file-url: https://unpkg.com/@rnbws/renecss/package.json
static-checking: localIsNew

create-release:
needs: version-check
if: needs.version-check.outputs.changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Create Tag and GitHub Release
if: needs.version-check.outputs.changed == 'true'
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
with:
tag_name: v${{ needs.version-check.outputs.version }}
release_name: Release v${{ needs.version-check.outputs.version }}
29 changes: 11 additions & 18 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,20 @@ You’ll find the generated file at `/dist/rene.min.css`
## Publish a new package

Considering you already have an NPM account, with NPM and Node.js installed on your local machine.
To publish a new package version, follow these simple steps:
1. Update `package.json`: Increment the version number in your `package.json` file according to semantic versioning.
2. Commit Changes.
3. Push Changes in `main` branch.
4. GitHub Actions will automatically trigger the workflow to create a release based on the updated version in `package.json` and publish the new package version.

1. Open a terminal to login into your NPM account and fill out your username, email and password as requested.
### GitHub Actions Workflow Overview

```
npm login
```

> You might also be asked for a one-time-password if there is 2FA applied on your account.
2. Now, update the version in your `package.json` file. You can use the [SemVer](https://semver.org/) format for versioning.

3. Ensure there is nothing left to commit and commit any pending work. Then run the below command.

```
npm publish --access public
```

4. Once publishing is completed, `np` will prompt a browser window for adding the release notes to GitHub. Fill in the details.
The workflow file [`release-on-version-change.yml`](https://github.com/VictoriaShyika/rene.css/blob/release-and-npm-publish/.github/workflows/release-on-version-change.yml) runs ***Version Check*** and ***Release Creation*** actions.
The workflow file [`publish-npm-package.yml`](https://github.com/VictoriaShyika/rene.css/blob/release-and-npm-publish/.github/workflows/publish-npm-package.yml) runs ***Publish NPM Package*** action.

That’s all! Your package is published!
1. ***Version Check***: Checks if the version in the `npm package.json` matches the version in the GitHub repository.
2. ***Release Creation***: Creates a GitHub release when the version in `npm package.json` is different from the version in the GitHub repository.
3. ***Publish NPM Package***: Publishes a new package version when a release is created.

## Code of Conduct

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "renecss",
"version": "1.3.2",
"name": "@rnbws/renecss",
"version": "0.0.1",
"description": "Rene is a design system for intention and meaning",
"main": "rene.css",
"scripts": {
Expand All @@ -10,7 +10,13 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/relateapp/rene.git"
"url": "git+https://github.com/rnbwdev/rene.css.git"
},
"publishConfig": {
"publishConfig": {
"@rnbws:registry": "https://npm.pkg.github.com",
"access": "public"
}
},
"keywords": [
"css",
Expand All @@ -21,9 +27,9 @@
"author": "Relate Design LTD",
"license": "MIT",
"bugs": {
"url": "https://github.com/relateapp/rene/issues"
"url": "https://github.com/rnbwdev/rene.css/issues"
},
"homepage": "https://github.com/relateapp/rene#readme",
"homepage": "https://github.com/rnbwdev/rene.css#readme",
"devDependencies": {
"css-loader": "^6.7.1",
"css-minimizer-webpack-plugin": "^3.4.1",
Expand Down

0 comments on commit 7bda374

Please sign in to comment.