-
Notifications
You must be signed in to change notification settings - Fork 169
93 lines (81 loc) · 3.61 KB
/
reusable-publish.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
89
90
91
92
93
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.- .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-' `-`-' `-`-'
#
# Reusable workflow that builds the code and publishes the packages
#
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.- .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-' `-`-' `-`-'
name: Publish packages
on:
workflow_call:
# We'll default the NPM_TOKEN to an empty value since we use it
# in .npmrc file and if undefined, the node setup would fail
env:
NPM_TOKEN: ""
jobs:
publish:
name: Publish
runs-on: ubuntu-latest-4xlarge
# We'll run the job on the prebuilt base image
container:
image: ghcr.io/layerzero-labs/devtools-dev-base:main
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: "true"
token: ${{ secrets.LAYERZERO_BOT_GITHUB_TOKEN }}
# Workaround for dubious ownership problem inside a containerized workflow
#
# See https://github.com/actions/runner-images/issues/6775
#
# A possible solution to investigate is to use the 1001 user
# https://github.com/actions/runner/issues/2033#issuecomment-1598547465
- name: Transfer file ownership to the root user
shell: bash
run: chown -R root .
- name: Setup environment
uses: ./.github/workflows/actions/setup-environment
- name: Install dependencies
uses: ./.github/workflows/actions/install-dependencies
- name: Setup build cache
uses: ./.github/workflows/actions/setup-build-cache
# We'll run the build in series to avoid race conditions
# when compiling hardhat projects in monorepo setups
- name: Build
run: pnpm build
env:
NODE_ENV: production
# This step uses the changesets CLI to bump the package versions and/or publish the unpublished packages
#
# How this works is:
#
# - If there are any changesets (markdown files in the .changeset directory),
# changesets CLI will bump the package versions according to the bumps specified in the markdown files.
#
# - A PR is created containing these version bumps and with the changeset markdowns deleted
#
# - Once this PR is merged, this workflow kicks in again and this time checks
# whether there is anything that needs to be published
- name: Publish packages / create version bump PRs
uses: changesets/action@v1
with:
version: pnpm release:version
publish: pnpm release:publish
title: "🚀 Version packages"
env:
# This is here because changesets/action will look for the .npmrc
# in HOME folder and if it doesn't find one there it will create one
#
# Since we want to make sure it uses our .npmrc we'll just point it
# to our workspace root (which, in a workflow that uses a container, is put under __w directory)
#
# Here we need to use the ${{ env.GITHUB_WORKSPACE }} environment variable instead
# of the github context value ${{ github.workspace }}
#
# See more here https://github.com/actions/runner/issues/2058
HOME: ${{ env.GITHUB_WORKSPACE }}
GITHUB_TOKEN: ${{ secrets.LAYERZERO_BOT_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISHER }}