Skip to content

Commit 54509f2

Browse files
committed
ci: [ci skip] update publish action
chore: fix docker build for hydra-indexer and hydra-indexer-gateway affects: @dzlzv/hydra-indexer-gateway, @dzlzv/hydra-indexer
1 parent 3a1b848 commit 54509f2

File tree

4 files changed

+39
-16
lines changed

4 files changed

+39
-16
lines changed

.github/workflows/publish.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: publish
22
on:
33
workflow_dispatch: # manually run
44
inputs:
5+
packages:
6+
description: 'Comma-separated list of packages to publish'
7+
required: true
8+
default: '*'
59
graduate:
610
description: 'Graduate from prerelease'
711
required: false
@@ -34,29 +38,41 @@ jobs:
3438
yarn install --frozen-lockfile
3539
git config --global user.name 'github-actions'
3640
git config --global user.email '[email protected]'
37-
- name: Lerna graduate
41+
42+
- name: Lerna graduate and publish
3843
if: github.event.inputs.graduate == 'true'
3944
run: |
40-
yarn lerna version --conventional-commits --conventional-graduate --yes
45+
yarn lerna version --conventional-commits --conventional-graduate '${{ github.event.inputs.packages }}' --yes
46+
yarn lerna publish from-git --dist-tag latest --yes --conventional-commits
4147
42-
- name: Lerna publish
48+
- name: Lerna publish current package
49+
if: github.event.inputs.graduate == 'false'
4350
run: |
44-
yarn lerna publish from-git --dist-tag latest --yes --conventional-commits
51+
yarn lerna publish from-package --dist-tag next --yes --conventional-commits --conventional-prerelease '${{ github.event.inputs.packages }}'
52+
4553
- name: Docker login
54+
if: "!contains(github.event.inputs.packages, 'hydra-indexer') || github.event.inputs.packages == '*'"
4655
uses: docker/login-action@v1
4756
with:
4857
username: ${{ secrets.DOCKER_USERNAME }}
4958
password: ${{ secrets.DOCKER_PASSWORD }}
50-
- uses: satackey/[email protected]
51-
# Ignore the failure of a step and avoid terminating the job.
52-
continue-on-error: true
59+
5360
- name: Docker build
61+
if: "contains(github.event.inputs.packages, 'hydra-indexer') || github.event.inputs.packages == '*'"
5462
run: |
5563
docker build . -t hydra-builder:latest
64+
5665
- name: Publish hydra-indexer image
66+
if: "contains(github.event.inputs.packages, 'hydra-indexer') || github.event.inputs.packages == '*'"
5767
run: |
58-
yarn workspace @dzlzv/hydra-indexer docker:publish
59-
68+
(cd ./packages/hydra-indexer && yarn docker:publish)
69+
env:
70+
RELEASE_TAG: ${{ github.event.inputs.graduate == 'true' && 'latest' || 'next' }}
71+
6072
- name: Publish hydra-indexer-gateway image
73+
if: "contains(github.event.inputs.packages, 'hydra-indexer-gateway') || github.event.inputs.packages == '*'"
6174
run: |
62-
yarn workspace @dzlzv/hydra-indexer-gateway docker:publish
75+
(cd ./packages/hydra-indexer-gateway && yarn docker:publish)
76+
env:
77+
RELEASE_TAG: ${{ github.event.inputs.graduate == 'true' && 'latest' || 'next' }}
78+

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ A pull request adding a new feature or fixing an existing bug should include a t
99
## Versioning and Releases
1010

1111
The monorepo is organized with lerna, with a single version for all packages. Once a pull request is merged, the version is bumped to the new pre-release version following the conventional commits convention. When deemed mature, the `publish` action can be manuually triggered. It graduates the pre-release version and publishes to the npm registry and docker hub (for private packages `hydra-indexer` and `hydra-indexer-gateway`).
12+
13+
## Publishing (for maintainers only)
14+
15+
`Publish` Github action is supposed to be run manually. It has the following inputs:
16+
17+
- `packages`: specify the list of packages to publish. If the list containts `hydra-indexer` and/or `hydra-indexer-gateway` then the corresponding Docker images will be published to Dockerhub. By default, it is set to `'*'` which means that both npm packages and Docker images will be published
18+
19+
- `graduate`: Whether the current pre-release should be [graduated](https://github.com/lerna/lerna/blob/main/commands/version/README.md#--conventional-graduate) by Lerna. For examaple, `2.0.1-alpha.3` will be graduated to `2.0.1`. Graduated releases are published with the `latest` tag, while `pre-releases` has `next`.

packages/hydra-indexer-gateway/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"description": "Generated Warthog Project",
66
"license": "MIT",
77
"scripts": {
8-
"docker:build": "docker build . -t joystream/hydra-indexer-gateway:latest -t joystream/hydra-indexer-gateway:${TAG:-latest} -t hydra-indexer-gateway:latest",
9-
"docker:push": "docker push joystream/hydra-indexer-gateway",
10-
"docker:publish": "export TAG=$(node -p 'require(\"./package.json\").version') && yarn docker:build && yarn docker:push",
8+
"docker:build": "docker build . -t joystream/hydra-indexer-gateway:${VERSION_TAG:-0.0.0} -t joystream/hydra-indexer-gateway:${RELEASE_TAG:-next} -t hydra-indexer-gateway:latest",
9+
"docker:push": "docker push joystream/hydra-indexer-gateway --all-tags",
10+
"docker:publish": "export VERSION_TAG=$(node -p 'require(\"./package.json\").version') && yarn docker:build && yarn docker:push",
1111
"bootstrap": "yarn bootstrap:dev",
1212
"bootstrap:dev": "yarn && yarn build:dev && yarn db:drop && yarn db:create && yarn db:migrate && yarn db:seed",
1313
"bootstrap:prod": "yarn && yarn build:prod && yarn start:prod",

packages/hydra-indexer/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
],
1616
"scripts": {
1717
"pub": "yarn build && yarn publish --access public",
18-
"docker:build": "docker build . -t joystream/hydra-indexer:latest -t hydra-indexer:latest",
19-
"docker:tag-latest": "docker tag joystream/hydra-indexer:latest joystream/hydra-indexer:${TAG}",
20-
"docker:publish": "export TAG=$(node -p 'require(\"./package.json\").version') && yarn docker:build && yarn docker:tag-latest && docker push joystream/hydra-indexer",
18+
"docker:build": "docker build . -t joystream/hydra-indexer:${VERSION_TAG:-0.0.0} -t joystream/hydra-indexer:${RELEASE_TAG:-next} -t hydra-indexer:latest",
19+
"docker:publish": "export VERSION_TAG=$(node -p 'require(\"./package.json\").version') && yarn docker:build && docker push joystream/hydra-indexer --all-tags",
2120
"build": "rm -rf lib && tsc --build tsconfig.json",
2221
"lint": "eslint . --cache --ext .ts",
2322
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js",

0 commit comments

Comments
 (0)