diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 0000000..54ee0f0 --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,51 @@ +# Compares the version in package.json to tags on the repo. If the tag doesn't exist, a new tag is created, which +# then triggers the normal "on tag" release automation in the build job +name: Auto Tag + +on: + push: + branches: + - main + +concurrency: + group: main-release-check + +jobs: + check-version: + name: Tag and Release + runs-on: ubuntu-latest + steps: + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main + + - name: Checkout current branch + uses: actions/checkout@v3 + with: + # Need PACKAGE_ADMIN_PAT token so when the tag is created, the tag automation runs + token: ${{ secrets.PACKAGE_ADMIN_PAT }} + fetch-depth: 0 + + - name: Configure commit signing for ChiaAutomation + uses: Chia-Network/actions/commit-sign/gpg@main + with: + gpg_private_key: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_KEY }} + passphrase: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_PASSPHRASE }} + + - name: Check for current version tag. Create if it doesn't exist + run: | + version=$(cat $GITHUB_WORKSPACE/package.json | jq -r '.version') + echo "Version is: $version" + + if [ $(git tag -l "$version") ]; then + echo "Tag exists, nothing to do" + else + echo "Tag does not exist. Creating and pushing tag" + rm -f CHANGELOG.md + npx conventional-changelog-cli -p angular -i CHANGELOG.md -s -r 0 + changes=$(npx conventional-changelog-cli -r 1 | tail -n +2) + git add CHANGELOG.md + git commit -m "chore: Updating changelog for $version" + git tag $version -m "Release $version \n$changes" + git push origin $version + git push origin main + fi diff --git a/.github/workflows/ensure-version-increment.yml b/.github/workflows/ensure-version-increment.yml new file mode 100644 index 0000000..bef149e --- /dev/null +++ b/.github/workflows/ensure-version-increment.yml @@ -0,0 +1,42 @@ +# This workflow runs on any PRs that are targeting main, and ensures that the version in package.json is incremented +name: Check Version Increment + +on: + pull_request: + branches: + - 'main' + +concurrency: + # SHA is added to the end if on `main` to let all main workflows run + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }} + cancel-in-progress: true + +jobs: + check-version: + name: Check version increment + runs-on: ubuntu-latest + steps: + - uses: Chia-Network/actions/clean-workspace@main + + - name: Checkout current branch + uses: actions/checkout@v3 + with: + path: branch-repo + + - name: Checkout main + uses: actions/checkout@v3 + with: + ref: main + path: main-repo + + - name: Check Versions + run: | + main_version=$(cat $GITHUB_WORKSPACE/main-repo/package.json | jq -r '.version') + branch_version=$(cat $GITHUB_WORKSPACE/branch-repo/package.json | jq -r '.version') + echo "Main version: $main_version" + echo "Branch version: $branch_version" + + if [[ "$branch_version" == "$main_version" ]]; then + echo "Version in package.json on this branch is not changing. Version must incremenet for a merge to main" + exit 1 + fi diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..f4c6415 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,31 @@ +name: Publish to NPM + +on: + release: + types: [published] + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }} + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node 18.x + uses: actions/setup-node@v3 + with: + node-version: "18" + + - name: Publish to NPM + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc + npm publish --access public + + - name: Cleanup + if: always() + run: rm .npmrc || true diff --git a/README.md b/README.md index ad08dd7..b572662 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -# node-template -Template repo for NodeJS-based projects +# Core Registry Logger example usage @@ -10,4 +9,4 @@ const logger = new Logger({ logLevel: 'info', packageVersion: '1.0.0' }); -``` \ No newline at end of file +``` diff --git a/package.json b/package.json index 2cfe509..aae25a4 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,30 @@ { - "name": "core-registry-logger", + "name": "@chia-carbon/core-registry-logger", "version": "1.0.0", "description": "Custom logger for core registry projects", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "author": "Michael Taylor", - "license": "ISC", + "author": "Chia Network", + "email": "hello@chia.net", + "url": "https://www.chia.net/", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "https://github.com/Chia-Network/core-registry-logger.git" + }, + "bugs":{ + "url": "https://github.com/Chia-Network/core-registry-logger/issues" + }, "dependencies": { "chia-root-resolver": "^1.0.0", "winston": "^3.10.0", "winston-daily-rotate-file": "^4.7.1" - } + }, + "contributors": [ + "Michael.Taylor ", + "Chris Marslender ", + "Zach Brown " + ] }