Skip to content

Commit

Permalink
ci: [ci skip] update publish action
Browse files Browse the repository at this point in the history
chore: fix docker build for hydra-indexer and hydra-indexer-gateway

affects: @dzlzv/hydra-indexer-gateway, @dzlzv/hydra-indexer
  • Loading branch information
dzhelezov committed Mar 5, 2021
1 parent 3a1b848 commit 54509f2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
36 changes: 26 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: publish
on:
workflow_dispatch: # manually run
inputs:
packages:
description: 'Comma-separated list of packages to publish'
required: true
default: '*'
graduate:
description: 'Graduate from prerelease'
required: false
Expand Down Expand Up @@ -34,29 +38,41 @@ jobs:
yarn install --frozen-lockfile
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
- name: Lerna graduate
- name: Lerna graduate and publish
if: github.event.inputs.graduate == 'true'
run: |
yarn lerna version --conventional-commits --conventional-graduate --yes
yarn lerna version --conventional-commits --conventional-graduate '${{ github.event.inputs.packages }}' --yes
yarn lerna publish from-git --dist-tag latest --yes --conventional-commits
- name: Lerna publish
- name: Lerna publish current package
if: github.event.inputs.graduate == 'false'
run: |
yarn lerna publish from-git --dist-tag latest --yes --conventional-commits
yarn lerna publish from-package --dist-tag next --yes --conventional-commits --conventional-prerelease '${{ github.event.inputs.packages }}'
- name: Docker login
if: "!contains(github.event.inputs.packages, 'hydra-indexer') || github.event.inputs.packages == '*'"
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: satackey/action-docker-layer-caching@v0.0.11
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true

- name: Docker build
if: "contains(github.event.inputs.packages, 'hydra-indexer') || github.event.inputs.packages == '*'"
run: |
docker build . -t hydra-builder:latest
- name: Publish hydra-indexer image
if: "contains(github.event.inputs.packages, 'hydra-indexer') || github.event.inputs.packages == '*'"
run: |
yarn workspace @dzlzv/hydra-indexer docker:publish
(cd ./packages/hydra-indexer && yarn docker:publish)
env:
RELEASE_TAG: ${{ github.event.inputs.graduate == 'true' && 'latest' || 'next' }}

- name: Publish hydra-indexer-gateway image
if: "contains(github.event.inputs.packages, 'hydra-indexer-gateway') || github.event.inputs.packages == '*'"
run: |
yarn workspace @dzlzv/hydra-indexer-gateway docker:publish
(cd ./packages/hydra-indexer-gateway && yarn docker:publish)
env:
RELEASE_TAG: ${{ github.event.inputs.graduate == 'true' && 'latest' || 'next' }}

8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ A pull request adding a new feature or fixing an existing bug should include a t
## Versioning and Releases

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`).

## Publishing (for maintainers only)

`Publish` Github action is supposed to be run manually. It has the following inputs:

- `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

- `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`.
6 changes: 3 additions & 3 deletions packages/hydra-indexer-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"description": "Generated Warthog Project",
"license": "MIT",
"scripts": {
"docker:build": "docker build . -t joystream/hydra-indexer-gateway:latest -t joystream/hydra-indexer-gateway:${TAG:-latest} -t hydra-indexer-gateway:latest",
"docker:push": "docker push joystream/hydra-indexer-gateway",
"docker:publish": "export TAG=$(node -p 'require(\"./package.json\").version') && yarn docker:build && yarn docker:push",
"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",
"docker:push": "docker push joystream/hydra-indexer-gateway --all-tags",
"docker:publish": "export VERSION_TAG=$(node -p 'require(\"./package.json\").version') && yarn docker:build && yarn docker:push",
"bootstrap": "yarn bootstrap:dev",
"bootstrap:dev": "yarn && yarn build:dev && yarn db:drop && yarn db:create && yarn db:migrate && yarn db:seed",
"bootstrap:prod": "yarn && yarn build:prod && yarn start:prod",
Expand Down
5 changes: 2 additions & 3 deletions packages/hydra-indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
],
"scripts": {
"pub": "yarn build && yarn publish --access public",
"docker:build": "docker build . -t joystream/hydra-indexer:latest -t hydra-indexer:latest",
"docker:tag-latest": "docker tag joystream/hydra-indexer:latest joystream/hydra-indexer:${TAG}",
"docker:publish": "export TAG=$(node -p 'require(\"./package.json\").version') && yarn docker:build && yarn docker:tag-latest && docker push joystream/hydra-indexer",
"docker:build": "docker build . -t joystream/hydra-indexer:${VERSION_TAG:-0.0.0} -t joystream/hydra-indexer:${RELEASE_TAG:-next} -t hydra-indexer:latest",
"docker:publish": "export VERSION_TAG=$(node -p 'require(\"./package.json\").version') && yarn docker:build && docker push joystream/hydra-indexer --all-tags",
"build": "rm -rf lib && tsc --build tsconfig.json",
"lint": "eslint . --cache --ext .ts",
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js",
Expand Down

0 comments on commit 54509f2

Please sign in to comment.