Skip to content

Commit

Permalink
chore: set up continuous delivery (#12)
Browse files Browse the repository at this point in the history
* chore: install nx semver

* chore: set up continous delivery

* chore: install ngx-deploy

* fix: publish command

* chore: update alpha version
  • Loading branch information
nacho-vazquez authored Aug 6, 2023
1 parent a2bc232 commit 8abecff
Show file tree
Hide file tree
Showing 8 changed files with 1,065 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {}
}
21 changes: 20 additions & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@ name: Setup

description: Setup Node.js, cache and install dependencies

inputs:
git_bot_token:
description: Git Bot token used to push to protected branches because github token can't
required: false


runs:
using: composite
steps:
# Needed for nx affected command, it set the BASE and HEAD env variables

- name: Checkout all commits
uses: actions/checkout@v3
with:
token: ${{ inputs.git_bot_token || github.token }}
fetch-depth: 0

# Needed for nx affected command, it set the BASE and HEAD env variables
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v3


- name: Setup git user to "🤖 naxode bot"
shell: bash
run: git config user.email "-" && git config user.name "🤖 naxodev bot"


- name: Determine Node.js version
id: node_version
shell: bash
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
- workflow_dispatch

jobs:
release:
runs-on: ubuntu-latest

if: github.ref == 'refs/heads/main'

steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
with:
git_bot_token: ${{ secrets.GIT_BOT_TOKEN }}

- name: Release
env:
NODE_AUTH_TOKEN: ${{ inputs.NPM_TOKEN }}
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
# Use npx instead of yarn because yarn automagically sets NPM_* environment variables
# like NPM_CONFIG_REGISTRY so npm publish ends up ignoring the .npmrc file
# which is set up by `setup-node` action.
shell: bash
run: npx nx affected --base=last-release --target=version

- name: Tag last-release
shell: bash
run: git tag -f last-release

- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ inputs.GITHUB_TOKEN }}
branch: ${{ github.ref }}
force: true
tags: true
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
"name": "@oss/source",
"version": "0.0.0",
"license": "MIT",
"scripts": {},
"scripts": {
"prepare": "husky install"
},
"private": true,
"devDependencies": {
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
"@jscutlery/semver": "^3.1.0",
"@nx/angular": "16.6.0",
"@nx/devkit": "16.6.0",
"@nx/eslint-plugin": "16.6.0",
Expand All @@ -26,8 +31,10 @@
"@typescript-eslint/parser": "^5.60.1",
"eslint": "~8.15.0",
"eslint-config-prettier": "8.1.0",
"husky": "^8.0.0",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"ngx-deploy-npm": "^6.0.0",
"nx": "16.6.0",
"nx-cloud": "16.2.0",
"prettier": "^2.6.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/nx-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@naxodev/nx-cloudflare",
"description": "Nx plugin for Cloudflare",
"homepage": "https://github.com/naxodev/oss/tree/main/packages/plugins/nx-cloudflare",
"version": "0.0.1-alpha-4",
"version": "0.0.1-alpha-5",
"author": "Nacho Vazquez",
"type": "commonjs",
"license": "MIT",
Expand Down
34 changes: 30 additions & 4 deletions packages/plugins/nx-cloudflare/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
]
}
},
"publish": {
"command": "node tools/scripts/publish.mjs plugins-nx-cloudflare {args.ver} {args.tag}",
"dependsOn": ["build"]
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
Expand All @@ -65,6 +61,36 @@
"codeCoverage": true
}
}
},
"version": {
"dependsOn": ["build"],
"executor": "@jscutlery/semver:version",
"options": {
"preset": "conventional",
"tagPrefix": "v",
"noVerify": true,
"push": true,
"preid": "beta",
"syncVersions": false,
"commitMessageFormat": "release(${projectName}): 🎸 cut release to ${version}",
"postTargets": [
"plugins-nx-cloudflare:github",
"plugins-nx-cloudflare:publish"
]
}
},
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "${tag}",
"notes": "${notes}"
}
},
"publish": {
"executor": "ngx-deploy-npm:deploy",
"options": {
"access": "public"
}
}
},
"tags": ["scope:public", "type:plugin"]
Expand Down
Loading

0 comments on commit 8abecff

Please sign in to comment.