-
Notifications
You must be signed in to change notification settings - Fork 1
70 lines (70 loc) · 2.29 KB
/
deploy.yml
File metadata and controls
70 lines (70 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Deploy
on:
push:
branches: [main]
tags: ["v*"]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-deploy
cancel-in-progress: false
jobs:
deploy-package:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # Required for OIDC authentication with npm
env:
DOCKER_IMAGE: package
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
# NOTE(krishan711): need full history to calculate difference
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build docker image
uses: docker/build-push-action@v2
with:
context: .
load: true
cache-from: type=gha,scope=package
cache-to: type=gha,mode=max,scope=package
tags: ${{ env.DOCKER_IMAGE }}
- name: Calculate commit count since last tag
id: vars
run: echo ::set-output name=commit_count::$(git rev-list $(git describe --tags --abbrev=0)..HEAD --count)
- name: Extract built package from Docker
run: |
docker create --name temp-container $DOCKER_IMAGE
docker cp temp-container:/app/. ./
docker rm temp-container
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Update npm to latest
run: npm install -g npm@latest
- name: Publish next package to npm
if: steps.vars.outputs.commit_count != '0' && github.ref == 'refs/heads/main'
run: npx kiba-publish --next --next-version ${{ steps.vars.outputs.commit_count }}
- name: Publish package to npm
if: startsWith(github.ref, 'refs/tags/v')
run: npm publish
create-release:
needs: deploy-package
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ github.ref_name }} \
--title "Release ${{ github.ref_name }}" \
--generate-notes