Skip to content

Commit

Permalink
Unify workflows (#130)
Browse files Browse the repository at this point in the history
* Unify workflows

* fix formatting

* Use bigger node

* Add docs to pipeline

* Comment if

* Change ignore parameters

* Removing fetch

* Fetching history

* Adding new branch

* Update docs before merge

* Restore code

* Create gh-pages

---------

Co-authored-by: ausias-armesto <[email protected]>
  • Loading branch information
ausias-armesto and ausias-armesto authored Oct 1, 2024
1 parent 52200be commit 29e93ee
Show file tree
Hide file tree
Showing 22 changed files with 4,587 additions and 196 deletions.
27 changes: 0 additions & 27 deletions .github/scripts/commit-and-push-all-changes.sh

This file was deleted.

11 changes: 0 additions & 11 deletions .github/scripts/config-git-info.sh

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# GitHub Workflows

This document describes the GitHub workflows used in this project.

## Build

Builds, Lint, Test and publish every commit on a pull request

The published artifact will have the version x.y.z-pr.<PR_NUMBER>+<BUILD_DATE>
The artifact will be published as well in the release channel `next` so it can be used as `@hoprnet/hopr-sdk@next`

## Merge PR

Exclusively publish the closure of a pull request in the alpha release channel so it can be used as `@hoprnet/hopr-sdk@alpha`

The published artifact will have the version x.y.z-pr.<PR_NUMBER>

## Close release

This is a workflow triggered manually from Github Actions [Close Release](https://github.com/hoprnet/hopr-sdk/actions/workflows/release.yaml). The tasks performed by this workflow include:

- Publish the version in the latest release channel so it can be used as `@hoprnet/hopr-sdk@latest`
- Publish the artifact with version x.y.z
- Published in the internal Google Artifact Registry and in public NPM registry
- Create a Github release
- Tag code
- Add a changelog to the Github release with the list of PR merged during this release
- Bumps the new version by opening a new PR
- Sends a Zulip notification
67 changes: 67 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build

on:
pull_request:
types: [synchronize, opened, reopened]

concurrency:
group: build
cancel-in-progress: true

jobs:
build:
name: Build
runs-on: self-hosted-hoprnet-big
strategy:
matrix:
node-version: [20.x, 22.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: hoprnet/hopr-workflows/actions/setup-node-js@master
with:
node-version: ${{ matrix.node-version }}

- name: Building
run: yarn build

- name: Linting
run: yarn lint:ci

- name: Formatting
run: yarn format:ci

- name: Testing
run: yarn test

publish:
name: Publish
runs-on: self-hosted-hoprnet-small
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: hoprnet/hopr-workflows/actions/setup-node-js@master
with:
node-version: ${{ vars.NODE_VERSION }}

- name: Setup GCP
id: gcp
uses: hoprnet/hopr-workflows/actions/setup-gcp@master
with:
google-credentials: ${{ secrets.GOOGLE_HOPRASSOCIATION_CREDENTIALS_REGISTRY }}
login-artifact-registry: 'true'

- name: Publish next version
run: |
BUILD_DATE=$(date +%Y%m%d%H%M%S)
PR_VERSION=$(jq -r '.version' package.json)-pr.${{ github.event.pull_request.number }}
jq --arg version "${PR_VERSION}-${BUILD_DATE}" '.version = $version' package.json > temp.json
mv temp.json package.json
yarn publish --no-git-tag-version --tag next
env:
NODE_AUTH_TOKEN: ${{ steps.gcp.outputs.access_token }}
49 changes: 0 additions & 49 deletions .github/workflows/docs.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Merge PR

on:
pull_request:
types: [synchronize]
push:
branches:
- main

concurrency:
group: docs
cancel-in-progress: false

jobs:
merge:
name: Merge PR
runs-on: self-hosted-hoprnet-small

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: hoprnet/hopr-workflows/actions/setup-node-js@master
with:
node-version: ${{ vars.NODE_VERSION }}

- name: Create docs
run: |
rm -rf docs/*
yarn docs
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: docs
cname: hoprnet.org
force_orphan: true
55 changes: 55 additions & 0 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Merge PR

on:
pull_request:
types:
- closed
branches:
- main

concurrency:
group: merge
cancel-in-progress: false

jobs:
merge:
name: Merge PR
runs-on: self-hosted-hoprnet-small
if: github.event.pull_request.merged == true

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: hoprnet/hopr-workflows/actions/setup-node-js@master
with:
node-version: ${{ vars.NODE_VERSION }}

- name: Setup GCP
id: gcp
uses: hoprnet/hopr-workflows/actions/setup-gcp@master
with:
google-credentials: ${{ secrets.GOOGLE_HOPRASSOCIATION_CREDENTIALS_REGISTRY }}
login-artifact-registry: 'true'

- name: Unpublish PR commit versions
run: |
gcloud artifacts versions list --repository=npm --location=europe-west3 --project=hoprassociation --package="${{ vars.NPM_PACKAGE_NAME }}" --format=json 2> /dev/null | jq -r ' .[] | select(.name | contains("-pr.${{ github.event.pull_request.number }}-")).name' | sed 's/.*versions\///g' > pr_commit_versions.txt
while read -r version; do
echo "Unpublishing commit version: $version"
gcloud artifacts versions delete --delete-tags --quiet --repository=npm --location=europe-west3 --project=hoprassociation --package "${{ vars.NPM_PACKAGE_NAME }}" $version
done < pr_commit_versions.txt
- name: Publish alpha version
run: |
BUILD_DATE=$(date +%Y%m%d%H%M%S)
PR_VERSION=$(jq -r '.version' package.json)-pr.${{ github.event.pull_request.number }}
jq --arg version "${PR_VERSION}-${BUILD_DATE}" '.version = $version' package.json > temp.json
mv temp.json package.json
yarn publish --no-git-tag-version --tag next
jq --arg version "${PR_VERSION}" '.version = $version' package.json > temp.json
mv temp.json package.json
yarn publish --no-git-tag-version --tag alpha
env:
NODE_AUTH_TOKEN: ${{ steps.gcp.outputs.access_token }}
74 changes: 0 additions & 74 deletions .github/workflows/node.js.yml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/publish.yml

This file was deleted.

Loading

0 comments on commit 29e93ee

Please sign in to comment.