From dfd8a32d3717176f1e8dfd716bf4a9ee2c6f0315 Mon Sep 17 00:00:00 2001 From: BOUHOURS Antoine Date: Tue, 5 Nov 2024 09:18:26 +0100 Subject: [PATCH] Replace release workflow and add node token as input Signed-off-by: BOUHOURS Antoine --- .github/workflows/publish.yml | 18 ----------- .github/workflows/release.yml | 56 +++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 18 deletions(-) delete mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 1c519ef8..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Publish -on: - release: - types: [ published ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org' - - run: npm install - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..a9a65158 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: Release + +on: + workflow_dispatch: + inputs: + versionType: + description: version type increment (major | minor | patch) + required: true + nodeAuthToken: + required: true + type: string +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Mask Node Auth Token + - run: | + NODE_AUTH_TOKEN=$(jq -r '.inputs.nodeAuthToken' $GITHUB_EVENT_PATH) + echo ::add-mask::$NODE_AUTH_TOKEN + echo NODE_AUTH_TOKEN=$NODE_AUTH_TOKEN >> $GITHUB_ENV + + - uses: actions/create-github-app-token@v1 + id: app-token + name: Generate app token + with: + app-id: ${{ vars.GRIDSUITE_ACTIONS_APPID }} + private-key: ${{ secrets.GRIDSUITE_ACTIONS_SECRET }} + + - name: Checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ steps.app-token.outputs.token }} + + - uses: actions/setup-node@v4 + with: + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' + + - name: Add release commit and publish + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + npm version ${{ github.event.inputs.versionType }} + git push origin main + git push origin $(git tag --points-at HEAD) + npm install + npm publish + env: + NODE_AUTH_TOKEN: ${{ env.NODE_AUTH_TOKEN }} + + - name: Create GitHub release + run: | + gh release create $(git tag --points-at HEAD) --generate-notes + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}