-
Notifications
You must be signed in to change notification settings - Fork 7
95 lines (82 loc) · 2.75 KB
/
build-and-publish.yml
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
89
90
91
92
93
94
95
name: Build and Publish
on:
workflow_dispatch: # Only manual trigger and only for the main branch
branches:
- main
inputs:
bump_level:
type: choice
description: Select bump level
required: true
options:
- patch
- minor
- major
env:
IMAGE_NAME: databricks-cdk-lambda
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GIT_TOKEN_DANIEL }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: |
npm install -g typescript
curl -sSL https://install.python-poetry.org | python3 - --version 1.2.2
- name: Docker login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB}}
- name: Build and publish
run: |
BUMP_LEVEL=${{ github.event.inputs.bump_level }}
echo "bump level: ${BUMP_LEVEL}"
# Version bump
cd typescript
# Install npm package
npm ci
NEW_VERSION=$(npm version "${BUMP_LEVEL}" | sed "s/^v//")
git config --local user.email "Bumpversion"
git config --local user.name "Bumpversion"
git add package.json package-lock.json
echo "new version: ${NEW_VERSION}"
npx tsc
cd ../aws-lambda
poetry version "${NEW_VERSION}"
poetry update
git add pyproject.toml poetry.lock
git commit -m "Bump version to ${NEW_VERSION}"
git tag "v${NEW_VERSION}"
# Docker build
docker build -t "${{ env.IMAGE_NAME }}:dev" .
docker tag "${{ env.IMAGE_NAME }}:dev" "godatadriven/${{ env.IMAGE_NAME }}:dev"
docker tag "${{ env.IMAGE_NAME }}:dev" "godatadriven/${{ env.IMAGE_NAME }}:${NEW_VERSION}"
docker push "godatadriven/${{ env.IMAGE_NAME }}:dev"
docker push "godatadriven/${{ env.IMAGE_NAME }}:${NEW_VERSION}"
cd ../typescript
npm publish
cd ../
git push
git push --tags
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: v${{ env.NEW_VERSION }}
release_name: v${{ env.NEW_VERSION }}
body: |
npm package: https://www.npmjs.com/package/databricks-cdk/v/${{ env.NEW_VERSION }}
draft: false
prerelease: false