diff --git a/.github/workflows/publish-npm-package.yml b/.github/workflows/publish-npm-package.yml new file mode 100644 index 0000000..44a3184 --- /dev/null +++ b/.github/workflows/publish-npm-package.yml @@ -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}} diff --git a/.github/workflows/release-on-version-change.yml b/.github/workflows/release-on-version-change.yml new file mode 100644 index 0000000..d175fa2 --- /dev/null +++ b/.github/workflows/release-on-version-change.yml @@ -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/version-check@v2.1.4 + 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/create-release@v1.1.4 + env: + GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }} + with: + tag_name: v${{ needs.version-check.outputs.version }} + release_name: Release v${{ needs.version-check.outputs.version }} diff --git a/contributing.md b/contributing.md index ffa85d4..2b30e6c 100644 --- a/contributing.md +++ b/contributing.md @@ -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 diff --git a/package-lock.json b/package-lock.json index f029fd8..d5874d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "renecss", - "version": "1.1.3", + "name": "@rnbws/renecss", + "version": "0.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "renecss", - "version": "1.1.3", + "name": "@rnbws/renecss", + "version": "0.0.1", "license": "MIT", "dependencies": { "np": "^7.6.2" diff --git a/package.json b/package.json index 904ccc5..cff07fd 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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", @@ -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",