-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (80 loc) · 2.58 KB
/
createTagAndReleaseAndPublish.yaml
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Create Tag And Release And Publish To NPM
on:
push:
branches:
- master
paths-ignore:
- '.github/**'
- '*.md'
- 'LICENSE'
jobs:
createTagAndRelease:
runs-on: ubuntu-latest
name: Create Tag And Release
permissions: write-all
outputs:
tagName: ${{ env.newTagName }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set Tag Name
id: setTag
uses: actions-opensource/get-next-tag@v1
- name: Create tag & Release
uses: actions/github-script@v6
# https://docs.github.com/en/rest/reference/releases#create-a-release
with:
script: |
console.log("newTagName=${{ env.newTagName }}")
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "${{ env.newTagName }}",
name: "${{ env.newTagName }}",
body: "Version ${{ env.newTagName }}",
target_commitish: context.sha
});
publishToNpm:
needs: [ createTagAndRelease ]
name: Publish Package to npmjs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm i
- run: npm run build
- run: npm version ${{ needs.createTagAndRelease.outputs.tagName }} --allow-same-version true --commit-hooks false --git-tag-version false
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publishToDockerHub:
needs: [ createTagAndRelease ]
name: Publish to docker hub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: barnuri/openapi-toolkit
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}