Skip to content

Commit

Permalink
Small pipeline updates (#13)
Browse files Browse the repository at this point in the history
* Small updates

* Update docs

* add notification

* fix format

* Remove node 21
  • Loading branch information
ausias-armesto authored Sep 17, 2024
1 parent 25cf2e0 commit 4cab129
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 34 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ The published artifact will have the version x.y.z-pr.<PR_NUMBER>

## Close release

Closes the release by publish the version in the latest release channel so it can be used as `@hoprnet/uhttp-crypto@latest`

The published artifact will have the version x.y.z
This is a workflow triggered manually from Github Actions [Close Release](https://github.com/hoprnet/uHTTP-crypto/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/uhttp-crypto@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
34 changes: 23 additions & 11 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ concurrency:
cancel-in-progress: true

jobs:
build-and-publish:
name: Build and Publish
build:
name: Build
runs-on: self-hosted-hoprnet-small
strategy:
matrix:
node-version: [20.x, 21.x, 22.x]
node-version: [20.x, 22.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -24,13 +24,6 @@ jobs:
with:
node-version: ${{ matrix.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: Building
run: yarn build

Expand All @@ -43,8 +36,27 @@ 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 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
if: matrix.node-version == vars.NODE_VERSION
run: |
BUILD_DATE=$(date +%Y%m%d%H%M%S)
PR_VERSION=$(node -p "require('./package.json').version")-pr.${{ github.event.pull_request.number }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ jobs:

- 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
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
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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ jobs:
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "current_version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
gcloud artifacts versions list --repository=npm --location=europe-west3 --project=hoprassociation --package=${{ vars.NPM_PACKAGE_NAME }} --format=json 2> /dev/null | jq --arg version "${PACKAGE_VERSION}-pr." -r ' .[] | select(.name | contains($version)).name' | sed "s/.*versions\/${PACKAGE_VERSION}-pr.//g" > pr_numbers.txt
gcloud artifacts versions list --repository=npm --location=europe-west3 --project=hoprassociation --package="${{ vars.NPM_PACKAGE_NAME }}" --format=json 2> /dev/null | jq --arg version "${PACKAGE_VERSION}-pr." -r ' .[] | select(.name | contains($version)).name' | sed "s/.*versions\/${PACKAGE_VERSION}-pr.//g" > pr_numbers.txt
echo "### Changelog" > changelog.md
echo "" >> changelog.md
while read -r pr_number; do
if [[ $pr_number == *"-"* ]]; then
echo "Deleting obsolete artifact ${PACKAGE_VERSION}-pr.${pr_number}"
gcloud artifacts versions delete --delete-tags --quiet --repository=npm --location=europe-west3 --project=hoprassociation --package ${{ vars.NPM_PACKAGE_NAME }} "${PACKAGE_VERSION}-pr.${pr_number}"
gcloud artifacts versions delete --delete-tags --quiet --repository=npm --location=europe-west3 --project=hoprassociation --package "${{ vars.NPM_PACKAGE_NAME }}" "${PACKAGE_VERSION}-pr.${pr_number}"
else
gh pr view ${pr_number} --json number,title | jq -r '"- #\(.number) - \(.title)"' >> changelog.md
fi
Expand All @@ -84,10 +84,10 @@ jobs:

- name: Unpublish PR 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("${{ steps.changelog.outputs.current_version }}-pr.")).name' | sed 's/.*versions\///g' > pr_versions.txt
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("${{ steps.changelog.outputs.current_version }}-pr.")).name' | sed 's/.*versions\///g' > pr_versions.txt
while read -r version; do
echo "Unpublishing PR version: $version"
gcloud artifacts versions delete --delete-tags --quiet --repository=npm --location=europe-west3 --project=hoprassociation --package ${{ vars.NPM_PACKAGE_NAME }} $version
gcloud artifacts versions delete --delete-tags --quiet --repository=npm --location=europe-west3 --project=hoprassociation --package "${{ vars.NPM_PACKAGE_NAME }}" $version
done < pr_versions.txt
- name: Publish to Google Artifact Registry
Expand Down
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@

Provides encryption and decryption functionality for uHTTP.

## Deployment
## Deployment process

### Staging

- staging can be deployed from any branch
- set a version tag manually in package.json with a suffix to differentiate it from the main versioning scheme (e.g. `-beta`)
- run publish action with `beta` tag from that branch

### Production

- production must be deployed from main
- run `yarn changeset version` to create the current changelog
- run `yarn build` to update version info
- commit everything, create a matching tag and push to main
- run publish action with `latest` tag
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)

0 comments on commit 4cab129

Please sign in to comment.