diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 0000000..09350ad --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,24 @@ +# GitHub Workflows + +This document describes the GitHub workflows used in this project. + +## Build + +Builds, Lint, Test on different node versions + +Publishes the docker image with version `x.y.z-pr.` + +## Merge PR + +Publishes the docker image with `latest` + +## Close release + +This is a workflow triggered manually from Github Actions [Close Release](https://github.com/hoprnet/uHTTP-latency-monitor/actions/workflows/release.yaml). The tasks performed by this workflow include: + +- Publishes the docker image with `x.y.z` +- Create a Github release +- Tag code +- Changelog is autogenerated by commit linear history of the release +- Bumps the new version by opening a new PR +- Sends a Zulip notification \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c5ffb6b..7800e07 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -9,10 +9,12 @@ concurrency: cancel-in-progress: true jobs: - build-and-publish: - name: Build and Push + build: + name: Build runs-on: self-hosted-hoprnet-small - + strategy: + matrix: + node-version: [20.x, 22.x] steps: - name: Checkout repository uses: actions/checkout@v4 @@ -20,18 +22,7 @@ jobs: - name: Setup Node.js uses: hoprnet/hopr-workflows/actions/setup-node-js@master with: - node-version: 20 - - - name: Setup GCP - uses: hoprnet/hopr-workflows/actions/setup-gcp@master - with: - google-credentials: ${{ secrets.GOOGLE_HOPRASSOCIATION_CREDENTIALS_REGISTRY }} - login-artifact-registry: 'true' - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - driver: kubernetes + node-version: ${{ matrix.node-version }} - name: Building run: yarn build @@ -45,14 +36,34 @@ jobs: - 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 GCP + id: gcp + uses: hoprnet/hopr-workflows/actions/setup-gcp@master + with: + google-credentials: ${{ secrets.GOOGLE_HOPRASSOCIATION_CREDENTIALS_REGISTRY }} + login-artifact-registry: 'true' + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: kubernetes + - name: Get PR version id: variables run: | - PR_VERSION=$(node -p "require('./package.json').version")-pr.${{ github.event.pull_request.number }} + PR_VERSION=$(jq -r '.version' ./package.json)-pr."${{ github.event.pull_request.number }}" echo "PR_VERSION=${PR_VERSION}" >> $GITHUB_OUTPUT - name: Build and push docker image uses: docker/build-push-action@v4 with: - push: true - tags: europe-west3-docker.pkg.dev/hoprassociation/docker-images/uhttp-latency-monitor:${{ steps.variables.outputs.PR_VERSION }} \ No newline at end of file + push: true + tags: ${{ vars.DOCKER_IMAGE_REGISTRY }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ steps.variables.outputs.PR_VERSION }} \ No newline at end of file diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml index ef741fd..7f68b2c 100644 --- a/.github/workflows/merge.yaml +++ b/.github/workflows/merge.yaml @@ -24,7 +24,7 @@ jobs: - name: Setup Node.js uses: hoprnet/hopr-workflows/actions/setup-node-js@master with: - node-version: 20 + node-version: ${{ vars.NODE_VERSION }} - name: Setup GCP id: gcp @@ -36,10 +36,10 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: - driver: kubernetes + driver: kubernetes - name: Build and push docker image uses: docker/build-push-action@v4 with: - push: true - tags: europe-west3-docker.pkg.dev/hoprassociation/docker-images/uhttp-latency-monitor:latest + push: true + tags: ${{ vars.DOCKER_IMAGE_REGISTRY }}/${{ vars.DOCKER_IMAGE_NAME }}:latest diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3b36cf1..8065e06 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,7 +29,7 @@ jobs: - name: Setup Node.js uses: hoprnet/hopr-workflows/actions/setup-node-js@master with: - node-version: 20 + node-version: ${{ vars.NODE_VERSION }} - name: Setup GCP id: gcp @@ -41,7 +41,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: - driver: kubernetes + driver: kubernetes - name: Building run: yarn build @@ -64,15 +64,14 @@ jobs: - name: Create Release uses: softprops/action-gh-release@v2 with: - name: 'uhttp-latency-monitor - v${{ steps.environment.outputs.release_version }}' + name: '${{ vars.DOCKER_IMAGE_NAME }} - v${{ steps.environment.outputs.release_version }}' tag_name: v${{ steps.environment.outputs.release_version }} - - name: Build and push docker image uses: docker/build-push-action@v4 with: - push: true - tags: europe-west3-docker.pkg.dev/hoprassociation/docker-images/uhttp-latency-monitor:${{ steps.environment.outputs.release_version }} + push: true + tags: ${{ vars.DOCKER_IMAGE_REGISTRY }}/${{ vars.DOCKER_IMAGE_NAME }}:${{ steps.environment.outputs.release_version }} - name: Bump Version id: bump @@ -93,7 +92,7 @@ jobs: delete-branch: true assignees: ${{ github.actor }} reviewers: 'esterlus' - team-reviewers: '@hoprnet/hopr-devops' + team-reviewers: '@hoprnet/hopr-products-team' - name: Notify new release uses: zulip/github-actions-zulip/send-message@v1 @@ -105,4 +104,4 @@ jobs: to: 'Releases' topic: 'main' content: | - I'm thrilled to inform the new **uhttp-latency-monitor** version **${{ steps.environment.outputs.release_version }}** has been released. \ No newline at end of file + I'm thrilled to inform the new **${{ vars.DOCKER_IMAGE_NAME }}** version **${{ steps.environment.outputs.release_version }}** has been released. \ No newline at end of file diff --git a/README.md b/README.md index ef13bad..ea1ffe0 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,7 @@ Measure roundtrip latency through uHTTP network. - Build container with `docker build -t uhttp-latency-monitor .` - Run container with `docker run --env-file .env --platform linux/amd64 uhttp-latency-monitor` + +## Deployment process + +To contribute to this repository you will need to create a pull request. More information about the existing automated workflows can be found in [GitHub Actions](./.github/workflows/README.md)