-
Notifications
You must be signed in to change notification settings - Fork 34
94 lines (84 loc) · 2.71 KB
/
release.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
name: Release
on:
push:
branches:
- main
# allow action to create tags and pull request
permissions:
contents: write
pull-requests: write
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
outputs:
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
# To use Turborepo Remote Caching
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install Dependencies
run: npm ci
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: npm run release
version: npm run version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
docker:
name: Publish to Docker Hub
needs: release
runs-on: ubuntu-latest
if: contains(needs.release.outputs.publishedPackages, 'caravan-coordinator')
steps:
- name: Parse Package Version
id: published
run: echo "version=$(echo '${{ needs.release.outputs.publishedPackages }}' | jq -r '.[] | select(.name=="caravan-coordinator").version')" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: caravanbitcoin/coordinator
tags: |
type=pep440,pattern={{version}},value=${{ steps.published.outputs.version }}
type=pep440,pattern={{major}}.{{minor}},value=${{ steps.published.outputs.version }}
type=sha
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./apps/coordinator/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}