From 9f23c4b5c9ad68d9cd2ea607f7c85b0b4370ecf4 Mon Sep 17 00:00:00 2001 From: ndr_brt Date: Mon, 6 May 2024 09:30:57 +0200 Subject: [PATCH] build: release workflow --- .../workflows/actions/npm-publish/action.yml | 33 ++++++++++++++ .github/workflows/npm-publish.yml | 37 ---------------- .github/workflows/publish-npm.yml | 10 +++++ .github/workflows/release.yml | 44 +++++++++++++++++++ .../{pull-request-testing.yml => test.yml} | 2 +- README.md | 3 ++ 6 files changed, 91 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/actions/npm-publish/action.yml delete mode 100644 .github/workflows/npm-publish.yml create mode 100644 .github/workflows/publish-npm.yml create mode 100644 .github/workflows/release.yml rename .github/workflows/{pull-request-testing.yml => test.yml} (97%) diff --git a/.github/workflows/actions/npm-publish/action.yml b/.github/workflows/actions/npm-publish/action.yml new file mode 100644 index 00000000..ed72a5e2 --- /dev/null +++ b/.github/workflows/actions/npm-publish/action.yml @@ -0,0 +1,33 @@ +name: Publish Package to npmjs + +runs: + using: "composite" + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js 18.x + uses: actions/setup-node@v4 + with: + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: | + node_modules + */*/node_modules + key: yarn-deps-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + shell: bash + run: yarn + + - name: Transpile to JavaScript + shell: bash + run: yarn transpile + + - run: npm publish --access=public + shell: bash + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml deleted file mode 100644 index 0182809e..00000000 --- a/.github/workflows/npm-publish.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Publish Package to npmjs - -on: - release: - types: [created] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout git repository - uses: actions/checkout@v4 - - - name: Use Node.js 18.x - uses: actions/setup-node@v4 - with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org' - - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: | - node_modules - */*/node_modules - key: yarn-deps-${{ hashFiles('**/yarn.lock') }} - - - name: Install dependencies - run: | - yarn - - - name: Transpile to JavaScript - run: yarn transpile - - - run: npm publish --access=public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 00000000..4821665c --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,10 @@ +name: publish npm + +on: + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + uses: ./.github/workflows/actions/npm-publish + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..caa7a552 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,44 @@ +name: release + +on: + workflow_dispatch: + inputs: + version: + description: 'SemVer that will be used for publishing (e.g. "0.0.1")' + required: true + type: string + +jobs: + prepare-release: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Prepare ${{ inputs.version }} release + run: | + git config user.name "think-it-account" + git config user.email "technical@think-it.io" + + sed -i 's/"version":.*/"version": "${{ inputs.version }}",/g' package.json + git add . + git commit -m "Prepare release ${{ inputs.version }}" + git push origin main + + git tag --force v${{ inputs.version }} + git push --force origin v${{ inputs.version }} + + - name: Create GitHub Release + uses: ncipollo/release-action@v1 + with: + generateReleaseNotes: true + tag: ${{ inputs.version }} + token: ${{ secrets.GITHUB_TOKEN }} + makeLatest: true + removeArtifacts: true + + publish: + needs: prepare-release + runs-on: ubuntu-latest + uses: ./.github/workflows/actions/npm-publish + secrets: inherit diff --git a/.github/workflows/pull-request-testing.yml b/.github/workflows/test.yml similarity index 97% rename from .github/workflows/pull-request-testing.yml rename to .github/workflows/test.yml index 5a22719e..593eed1f 100644 --- a/.github/workflows/pull-request-testing.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Pull request testing +name: test on: push: diff --git a/README.md b/README.md index cb62f5da..fb0082fb 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,9 @@ connectors with capabilities described in the Please, adhere to the [CONTRIBUTING](CONTRIBUTING.md) guidelines when suggesting changes in this repository. +### Release +The `release` github action workflow takes care of release. + ## License Copyright 2022-2023 Think.iT GmbH.