Skip to content

Commit

Permalink
ci: github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
aacerox committed Oct 19, 2023
1 parent 588166e commit f7a9fdb
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 98 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/nrc-job-apply-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
workflow_call:
inputs:
isRelease:
description: flag a release invocation
type: boolean
default: false
version:
description: version to apply to package.json files
type: string
required: true
jobs:
apply-version:
runs-on: ubuntu-latest
steps:
- id: checkout
name: checkout project
uses: actions/checkout@v3

- id: installNode
name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'

# generate changelog if its a release
- id: generateReleaseChangelog
name: create release changelog
if: ${{ inputs.isRelease }}
run: echo "generate change log"

# apply version to package.json files and create a git tag
- id: applyVersion
name: apply version to package.json files
env:
VERSION: ${{ inputs.version }}
IS_RELEASE: ${{ inputs.isRelease }}
run: |
export RELEASE_COMMENT=""
if [ "$IS_RELEASE" == "true" ]; then
RELEASE_COMMENT="release"
fi
npm version -m "apply $RELEASE_COMMENT version $VERSION"
# create release PR
- id: createReleasePR
name: create release PR
if: ${{ inputs.isRelease }}
run: echo "create release PR"





27 changes: 0 additions & 27 deletions .github/workflows/nrc-job-publish.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/nrc-job-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
on:
workflow_call:
jobs:
release:
runs-on: ubuntu-latest
if: ${{ github.repository == 'aacerox/node-rest-client' }}
steps:
# checkout repo
- uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
# read latest tag
- id: readLatestTag
name: read latest tag
run: echo "latestTag=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT"
# setup node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'
# install repo dependencies
- id: cleanInstallRepo
name: clean install repo
run: npm ci
# run changeset action
# - when push from normal PR: the 'version' command is executed. A new release branch and PR
# is created if it doesn't exists and if it does exists the commit is added to release branch
#
# - when push from release PR: the 'publish' command is executed and artifact are published to npm
- id: changesetPR
name: Changeset release
uses: changesets/action@v1
env:
NRC_RELEASE_MSG: "node-rest-client release ${{ steps.readLatestTag.outputs.latestTag }}"
GITHUB_TOKEN: ${{ secrets.NRC_GITHUB_TOKEN }}
with:
version: npm run version:packages
publish: npm run publish:packages
commit: "chore(release): ${{ env.NRC_RELEASE_MSG }}"
title: "${{ env.NRC_RELEASE_MSG }}"





27 changes: 13 additions & 14 deletions .github/workflows/nrc-workflow-ci.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
name: Node-Rest-Client CI
on:
push:
branches:
- feat/general-upgrade
branches:
- master
- release
- 'release/**'
# just one workflow active, for the same branch
concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
build-test:
# test
test:
uses: ./.github/workflows/nrc-job-build-test.yml
generate-version:
uses: ./.github/workflows/nrc-job-generate-version.yml
needs: build-test
print-version:
runs-on: ubuntu-latest
needs: generate-version
steps:
- run: echo "version used is $VERSION"
env:
VERSION: ${{ needs.generate-version.outputs.version }}

# changeset release
release:
uses: ./.github/workflows/nrc-job-release.yml





Expand Down
57 changes: 0 additions & 57 deletions .github/workflows/nrc-workflow-release.yml

This file was deleted.

0 comments on commit f7a9fdb

Please sign in to comment.