Skip to content

Commit 2b0aa18

Browse files
ci: migrate npm package publication to gha
1 parent 384b420 commit 2b0aa18

File tree

5 files changed

+75
-124
lines changed

5 files changed

+75
-124
lines changed

.drone-consider

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
.drone.yml
21
api/.drone.yml
3-
cli/.drone.yml

.drone.yml

Lines changed: 0 additions & 122 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: npm publish latest
2+
description: Publish on npm when a release is published
3+
4+
on:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
npm-publish:
10+
# only run for releases with tag 'iapp-v*' as created by release-please for CLI
11+
if: startsWith(github.ref_name,'iapp-v')
12+
uses: ./.github/workflows/reusable-cli-npm.yml
13+
with:
14+
tag: 'latest'
15+
secrets:
16+
npm-token: ${{ secrets.NPM_TOKEN }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: npm publish staging
2+
description: Publish a staging version on npm
3+
4+
on:
5+
workflow_dispatch:
6+
7+
jobs:
8+
compute-staging-version:
9+
uses: ./.github/workflows/reusable-compute-staging-version.yml
10+
with:
11+
working-directory: cli
12+
13+
npm-publish:
14+
uses: ./.github/workflows/reusable-cli-npm.yml
15+
needs: compute-staging-version
16+
with:
17+
version: ${{ needs.compute-staging-version.outputs.version }}
18+
tag: ${{ needs.compute-staging-version.outputs.dist-tag }}
19+
secrets:
20+
npm-token: ${{ secrets.NPM_TOKEN }}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Compute staging version
2+
description:
3+
compute a staging version from the current version, branch name and commit
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
working-directory:
9+
type: string
10+
required: true
11+
outputs:
12+
version:
13+
value: ${{ jobs.compute-staging-version.outputs.version }}
14+
dist-tag:
15+
value: ${{ jobs.compute-staging-version.outputs.dist-tag }}
16+
17+
jobs:
18+
compute-staging-version:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20'
27+
- name: Set publish version
28+
id: set-publish-version
29+
working-directory: ${{ inputs.working-directory }}
30+
run: |
31+
BRANCH=$(echo "${{ github.ref_name }}" | sed 's|/|-|g')
32+
COMMIT_SHA="${{ github.sha }}"
33+
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
34+
STAGING_VERSION="${CURRENT_VERSION}-${BRANCH}-${COMMIT_SHA::7}"
35+
echo "VERSION=${STAGING_VERSION}" | tee -a $GITHUB_OUTPUT
36+
echo "DIST_TAG=${BRANCH}" | tee -a $GITHUB_OUTPUT
37+
outputs:
38+
version: ${{ steps.set-publish-version.outputs.VERSION }}
39+
dist-tag: ${{ steps.set-publish-version.outputs.DIST_TAG }}

0 commit comments

Comments
 (0)