-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Add automated semantic release using Goreleaser (#357)
Co-authored-by: Ankur Banerjee <ankurdotb@users.noreply.github.com>
- Loading branch information
Showing
12 changed files
with
10,517 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,123 @@ | ||
name: "Release" | ||
on: | ||
workflow_call: | ||
inputs: | ||
RELEASE_VERSION: | ||
description: "Release version number" | ||
type: string | ||
defaults: | ||
run: | ||
shell: bash | ||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
|
||
jobs: | ||
|
||
release-packages: | ||
name: "Release cheqd-noded binary" | ||
release-binary: | ||
name: "Node binary" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
env: | ||
RELEASE_VERSION: ${{ inputs.RELEASE_VERSION }} | ||
outputs: | ||
RELEASE_VERSION: ${{ steps.set-version.outputs.RELEASE_VERSION }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Required to fetch version | ||
|
||
- name: Download node binary from build stage | ||
uses: actions/download-artifact@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
name: cheqd-noded | ||
path: build-tools | ||
go-version-file: ./go.mod | ||
cache: true | ||
|
||
- name: Restore binary permissions | ||
run: sudo chmod +x build-tools/cheqd-noded | ||
# Node.js setup is needed to run Semantic Release | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: 'npm' | ||
cache-dependency-path: '**/package-lock.json' | ||
|
||
- name: "Obtain Github App token" | ||
id: app-token | ||
uses: getsentry/action-github-app-token@v1.0.6 | ||
with: | ||
app_id: ${{ secrets.BOT_APP_ID }} | ||
private_key: ${{ secrets.BOT_APP_PRIVATE_KEY }} | ||
|
||
- name: "Install Semantic Release dependencies" | ||
run: npm ci | ||
|
||
- name: "Execute Semantic Release" | ||
run: npx semantic-release | ||
env: | ||
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | ||
|
||
- uses: "marvinpinto/action-automatic-releases@latest" | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v3 | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
automatic_release_tag: "${{ env.GITHUB_REF_NAME }}" | ||
prerelease: true | ||
draft: true | ||
files: | | ||
build-tools/cheqd-noded | ||
release-docker-images: | ||
name: "Publish Docker images for new version" | ||
distribution: goreleaser | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set release version number | ||
id: set-version | ||
run: | | ||
RELEASE_VERSION=$( git describe --tags ${{ github.sha }}) | ||
echo ::set-output name=RELEASE_VERSION::"$RELEASE_VERSION" | ||
release-docker: | ||
name: "Docker image" | ||
needs: release-binary | ||
runs-on: ubuntu-latest | ||
env: | ||
REGISTRY: ghcr.io | ||
RELEASE_VERSION: ${{ inputs.RELEASE_VERSION }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Required to fetch version | ||
|
||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version-file: ./go.mod | ||
cache: true | ||
|
||
- name: Generate golang code | ||
run: make proto-gen | ||
|
||
- name: Build cheqd-cli Docker image 'cheqd-noded' as entrypoint and no build args | ||
run: docker build --target base -t cheqd-cli -f docker/Dockerfile . | ||
|
||
- name: Build cheqd-node Docker image with 'node-start' as entrypoint and no build args | ||
run: docker build --target node -t cheqd-node -f docker/Dockerfile . | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
id: buildx | ||
with: | ||
version: latest | ||
|
||
- name: Login to Container registry | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Configure Docker image metadata | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ github.repository}} | ||
flavor: | | ||
latest=auto | ||
tags: | | ||
type=semver,pattern={{version}},value=${{ needs.release-binary.outputs.RELEASE_VERSION }} | ||
labels: | | ||
org.opencontainers.image.title="cheqd Node Docker Image" | ||
org.opencontainers.image.description="Node for cheqd network" | ||
org.opencontainers.image.source="https://github.com/cheqd/cheqd-node" | ||
org.opencontainers.image.vendor="Cheqd Foundation Limited" | ||
org.opencontainers.image.created={{date 'dddd, MMMM Do YYYY, h:mm:ss a'}} | ||
org.opencontainers.image.documentation="https://docs.cheqd.io/node" | ||
- name: Push cheqd-node image | ||
run: | | ||
docker tag cheqd-node ghcr.io/${{ github.repository }}:${{ env.RELEASE_VERSION }} | ||
docker tag cheqd-node ghcr.io/${{ github.repository }}:latest | ||
docker push ghcr.io/${{ github.repository }}:${{ env.RELEASE_VERSION }} | ||
docker push ghcr.io/${{ github.repository }}:latest | ||
- name: Push cheqd-cli image | ||
run: | | ||
docker tag cheqd-cli ghcr.io/${{ github.repository_owner }}/cheqd-cli:${{ env.RELEASE_VERSION }} | ||
docker tag cheqd-cli ghcr.io/${{ github.repository_owner }}/cheqd-cli:latest | ||
docker push ghcr.io/${{ github.repository_owner }}/cheqd-cli:${{ env.RELEASE_VERSION }} | ||
docker push ghcr.io/${{ github.repository_owner }}/cheqd-cli:latest | ||
- name: Build and push image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: docker/Dockerfile | ||
platforms: linux/amd64 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
### APP-SPECIFIC EXCLUSIONS ### | ||
build/ | ||
dist/ | ||
|
||
# Tests | ||
**/network-config | ||
|
Oops, something went wrong.