Skip to content

feat: create release-it-to-npm-with-pr-only #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/release-it-with-npm-and-pr-only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: release-with-npm-and-pr-only

on: workflow_dispatch

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Build
run: yarn build

- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact
path: build

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Lint
run: yarn lint

release:
name: Release
runs-on: ubuntu-latest
needs: [build, lint]

steps:
# (1) Create a GitHub App token
# Note: the Github App must be installed on the repository and included in the bypass list of the ruleset.
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}

- name: Checkout
uses: actions/checkout@v4
with:
# (2) Use the GitHub App token to init the repository
token: ${{ steps.app-token.outputs.token }}
# (3) Fetch all history so that release-it can determine the version
fetch-depth: 0

- name: Setup
uses: ./.github/actions/setup

# (4) Configure Git user
- name: Configure Git User
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"

- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact

- name: Release
run: yarn release
env:
# (5) Make GITHUB_TOKEN available to release-it but use the GitHub App token
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
# (6) Make NPM_ACCESS_TOKEN available to release-it and npm publish command
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_ACCESS_TOKEN}
8 changes: 3 additions & 5 deletions .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
"release": true
},
"npm": {
"publish": false
"publish": true
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": {
"name": "angular",
"types": {
"feat": {
"section": "Features",
"hidden": false
"section": "Features"
},
"fix": {
"section": "Bug Fixes",
"hidden": false
"section": "Bug Fixes"
}
}
},
Expand Down
33 changes: 29 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
{
"name": "github-actions-playground",
"name": "ga-playground",
"description": "Playground to learn and save all github-actions template I use on my open source projects.",
"version": "0.2.0",
"version": "1.0.0",
"packageManager": "yarn@4.6.0",
"author": "Mirko Quaglia <gladiusservices@protonmail.com> (https://github.com/gladiuscode)",
"main": "build/index",
"source": "src/index",
"files": [
"src",
"build",
"!**/__tests__",
"!**/__fixtures__",
"!**/__mocks__"
],
"scripts": {
"release": "release-it",
"release": "release-it --ci --dry-run",
"build": "tsc",
"lint": "eslint ./src"
},
Expand All @@ -19,5 +29,20 @@
},
"engines": {
"node": "=18.20.6"
}
},
"keywords": [
"github-actions",
"github",
"actions",
"playground",
"template"
],
"repository": {
"type": "git",
"url": "git+https://github.com/gladiuscode/github-actions-playground.git"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"license": "MIT"
}