Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add automated version tagging for CI/CD pipeline #229

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/common_tagging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Common Tagging Tasks

on:
workflow_call:
inputs:
DIST_VERSION_PREFIX:
required: true
type: string
outputs:
next_tag:
description: "The next tag outputs string"
value: ${{ jobs.tagging.outputs.next_tag }}

jobs:
tagging:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Determine Next Tag
id: determine_tag
run: |
YEAR=$(date +"%y")
MONTH=$(date +"%-m")
DAY=$(date +"%-d")
DATE_TAG="v${YEAR}.${MONTH}.${DAY}"

git fetch --tags

LATEST_TAG=$(git tag -l "${{ inputs.DIST_VERSION_PREFIX }}-${DATE_TAG}-*" | sort -V | tail -n 1)

if [ -z "$LATEST_TAG" ]; then
NEXT_TAG="${DATE_TAG}-1"
else
COUNTER=$(echo "$LATEST_TAG" | awk -F '-' '{print $NF}')
NEXT_TAG="${DATE_TAG}-$((COUNTER + 1))"
fi

FULL_TAG="${{ inputs.DIST_VERSION_PREFIX }}-$NEXT_TAG"

echo "NEXT_TAG=$FULL_TAG" >> $GITHUB_ENV
echo "next_tag=$FULL_TAG" >> $GITHUB_OUTPUT

- name: Create and Push Tag
run: |
git tag "$NEXT_TAG"
git push origin "$NEXT_TAG"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

outputs:
next_tag: ${{ steps.determine_tag.outputs.next_tag }}
24 changes: 6 additions & 18 deletions .github/workflows/executor_cd_preprod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,9 @@ jobs:
echo "${{ secrets.DOCKERHUB_KEY }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin

docker push "${IMAGE_NAME}"
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Dist Version
run: |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})

tagging:
needs: deploy
uses: ./.github/workflows/common_tagging.yml
with:
DIST_VERSION_PREFIX: "executor-preprod"
24 changes: 6 additions & 18 deletions .github/workflows/executor_cd_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,9 @@ jobs:
echo "${{ secrets.DOCKERHUB_KEY }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin

docker push "${IMAGE_NAME}"
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Dist Version
run: |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})

tagging:
needs: deploy
uses: ./.github/workflows/common_tagging.yml
with:
DIST_VERSION_PREFIX: "executor-prod"
24 changes: 6 additions & 18 deletions .github/workflows/executor_cd_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,9 @@ jobs:

docker push "${IMAGE_NAME}"
docker push "${SHA_IMAGE_NAME}"
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Dist Version
run: |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})

tagging:
needs: deploy
uses: ./.github/workflows/common_tagging.yml
with:
DIST_VERSION_PREFIX: "executor-staging"
24 changes: 6 additions & 18 deletions .github/workflows/miner_cd_preprod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,9 @@ jobs:
echo "${{ secrets.DOCKERHUB_KEY }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin

docker push "${IMAGE_NAME}"
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Dist Version
run: |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})

tagging:
needs: deploy
uses: ./.github/workflows/common_tagging.yml
with:
DIST_VERSION_PREFIX: "miner-preprod"
24 changes: 6 additions & 18 deletions .github/workflows/miner_cd_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,9 @@ jobs:
echo "${{ secrets.DOCKERHUB_KEY }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin

docker push "${IMAGE_NAME}"
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Dist Version
run: |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})

tagging:
needs: deploy
uses: ./.github/workflows/common_tagging.yml
with:
DIST_VERSION_PREFIX: "miner-prod"
24 changes: 6 additions & 18 deletions .github/workflows/miner_cd_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,9 @@ jobs:

docker push "${IMAGE_NAME}"
docker push "${SHA_IMAGE_NAME}"
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Dist Version
run: |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})

tagging:
needs: deploy
uses: ./.github/workflows/common_tagging.yml
with:
DIST_VERSION_PREFIX: "miner-staging"
24 changes: 6 additions & 18 deletions .github/workflows/miner_runner_cd_preprod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,9 @@ jobs:

docker push "${IMAGE_NAME}"
docker push "${SHA_IMAGE_NAME}"
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Dist Version
run: |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})

tagging:
needs: deploy
uses: ./.github/workflows/common_tagging.yml
with:
DIST_VERSION_PREFIX: "miner-runner-preprod"
24 changes: 6 additions & 18 deletions .github/workflows/miner_runner_cd_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,9 @@ jobs:

docker push "${IMAGE_NAME}"
docker push "${SHA_IMAGE_NAME}"
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Dist Version
run: |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})

tagging:
needs: deploy
uses: ./.github/workflows/common_tagging.yml
with:
DIST_VERSION_PREFIX: "miner-runner-prod"
24 changes: 6 additions & 18 deletions .github/workflows/miner_runner_cd_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,9 @@ jobs:

docker push "${IMAGE_NAME}"
docker push "${SHA_IMAGE_NAME}"
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Dist Version
run: |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})

tagging:
needs: deploy
uses: ./.github/workflows/common_tagging.yml
with:
DIST_VERSION_PREFIX: "miner-runner-staging"
24 changes: 6 additions & 18 deletions .github/workflows/validator_cd_preprod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,9 @@ jobs:
echo "${{ secrets.DOCKERHUB_KEY }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin

docker push "${IMAGE_NAME}"
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Dist Version
run: |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})

tagging:
needs: deploy
uses: ./.github/workflows/common_tagging.yml
with:
DIST_VERSION_PREFIX: "validator-preprod"
24 changes: 6 additions & 18 deletions .github/workflows/validator_cd_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,9 @@ jobs:
echo "${{ secrets.DOCKERHUB_KEY }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin

docker push "${IMAGE_NAME}"
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Dist Version
run: |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})

tagging:
needs: deploy
uses: ./.github/workflows/common_tagging.yml
with:
DIST_VERSION_PREFIX: "validator-prod"
24 changes: 6 additions & 18 deletions .github/workflows/validator_cd_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,9 @@ jobs:

docker push "${IMAGE_NAME}"
docker push "${SHA_IMAGE_NAME}"
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Dist Version
run: |
BUILD_NUMBER="${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
echo "DIST_VERSION=${DIST_VERSION_PREFIX}-${{ steps.date.outputs.date }}-${BUILD_NUMBER}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})

tagging:
needs: deploy
uses: ./.github/workflows/common_tagging.yml
with:
DIST_VERSION_PREFIX: "validator-staging"
Loading