-
Notifications
You must be signed in to change notification settings - Fork 25
102 lines (85 loc) · 3.59 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
95
96
97
98
99
100
101
102
name: Release
# Taken from: https://github.com/changesets/action#with-publishing
on:
workflow_dispatch:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Changelog PR or Release
if: ${{ github.repository_owner == 'kadena-community' }}
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
steps:
- uses: actions/checkout@v4
with:
show-progress: false
token: ${{ secrets.RELEASE_ACTION_GITHUB_TOKEN }}
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
graph:
- 'packages/apps/graph/**'
- name: Runner setup
uses: ./.github/actions/runner-setup
- name: Lint monorepo root
run: pnpm run lint
- name: Build, lint, test all packages
run: pnpm turbo lint build test
- name: Create Release PR or Publish
id: changesets
uses: changesets/action@v1
with:
# Note: pnpm install after versioning is necessary to refresh lockfile
version: pnpm run version
publish: pnpm run publish
commit: 'Update changelogs and bump versions'
title: '[ci] Release'
env:
# Needs "Contents" r+w and "Pull requests" r+w access to open/update PRs and push to main
GITHUB_TOKEN: ${{ secrets.RELEASE_ACTION_GITHUB_TOKEN }}
# Needs r+w access for packages of both orgs to publish to npm
NPM_TOKEN: ${{ secrets.RELEASE_ACTION_NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
- name: Output (debug)
if: steps.changesets.outputs.published == 'true'
# Do something more interesting when a publish happens.
run: echo ${{ steps.changesets.outputs.publishedPackages }}
- name: Checkout code
uses: actions/checkout@v3
- name: Log in GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Get version_id from GHCR for `@kadena/graph` latest version on NPM
id: npm-ghcr-version-id
run: |
latest_tag=$(npm view @kadena/graph --json | jq -r '."dist-tags".latest')
version_id=$(gh api "orgs/kadena-community/packages/container/graphql/versions" | \
jq --arg tag "$latest_tag" -r '.[] | select(.metadata.container.tags | index($tag)) | .id')
echo "::set-output name=version_id::$version_id"
- name: Build Docker Image for `:latest`
id: docker-build-graph-latest
# only run when npm-ghcr-version-id is empty
# when it's not empty, the image is already built
if: steps.npm-ghcr-version-id.outputs.version_id == ''
run: |
cd packages/apps/graph && \
docker compose build graphql --push --build-arg \
-t=ghcr.io/kadena/graphql:latest,ghcr.io/kadena/graphql:$(npm view @kadena/graph --json |jq '."dist-tags".latest')
- name: Build Docker Image `:preview`
id: docker-build-graph-preview
# no need to publish when `:latest` is publishing
if: steps.docker-build-graph-latest.conclusion != 'skipped' && steps.filter.outputs.graph == 'true'
# only run when `packages/apps/graph/**` has changes
run: |
cd packages/apps/graph && \
docker compose build graphql --push --build-arg \
-t=ghcr.io/kadena-community/graphql:preview,ghcr.io/kadena-community/graphql:sha-${GITHUB_SHA::7}