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

Conversation

hiroyukikumazawa
Copy link

Overview

This PR introduces a new GitHub Actions workflow, common_tagging.yml, that automates the tagging process for our CI/CD pipeline. The automated version tagging ensures consistent version management and supports changelog integration across different components of the Compute Horde monorepo. The tagging format follows <year>.<month>.<day>-<index>, incrementing if multiple releases occur on the same day.

Key Changes

  • New Workflow: common_tagging.yml added to handle common tagging tasks.

    • Inputs:
      • DIST_VERSION_PREFIX: Prefix for the distribution (e.g., executor-preprod).
    • Jobs:
      • Determines the next tag based on the current date and existing tags.
      • Creates and pushes the next tag to the repository.
  • Updates to Existing Workflows:

    • Workflows such as executor_cd_preprod.yml have been updated to utilize the new tagging workflow by calling common_tagging.yml.

Important Note: ACTIONS_PAT Secret

The ACTIONS_PAT secret is critical for the new tagging workflow to function correctly. It is a Personal Access Token (PAT) that allows the GitHub Actions runner to:

  • Fetch all tags from the repository.
  • Create and push new tags back to the repository.
Setting Up ACTIONS_PAT
  1. Generate a Personal Access Token (PAT):

    • Go to your GitHub account's Developer settings/Tokens (classic).
    • Click "Generate new token (classic)" and select the necessary permissions:
      • repo (Full control of private repositories).
      • workflow (Update GitHub Actions workflows).
    • Copy the generated token; it will not be shown again.
  2. Add the ACTIONS_PAT Secret to the Repository:

    • Navigate to the repository's Settings > Secrets and variables > Actions.
    • Click "New repository secret".
    • Name the secret ACTIONS_PAT and paste the copied token.

hiroyukikumazawa and others added 3 commits September 4, 2024 21:44
to support changelog integration and versioned builds.
- replaced the use of a personal access token (PAT) with GITHUB_TOKEN to enhance security.
- removed the  input from the workflow configuration.
@hiroyukikumazawa
Copy link
Author

hiroyukikumazawa commented Sep 12, 2024

@ppolewicz

In the tagging workflow, I have replaced the use of the personal access token (ACTIONS_PAT) with the GitHub-provided GITHUB_TOKEN.

Important Note:
To ensure the updated workflow functions correctly, we need to adjust the Workflow permissions settings in the repository's Actions settings. Please follow these steps:

  1. Go to Settings > Actions > General.
  2. Under Workflow permissions, ensure that "Read and write permissions" is selected.

I think this repo has already this setting based on current workflow.

.github/workflows/common_tagging.yml Outdated Show resolved Hide resolved
]

[tool.towncrier]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is towncrier part of this task scope? if not please clean it up

Copy link
Author

@hiroyukikumazawa hiroyukikumazawa Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

atm, the towncrier part is not used due to some conflict
but it's useful in the future

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mzukowski-reef what do you think?

.github/workflows/common_tagging.yml Outdated Show resolved Hide resolved
@hiroyukikumazawa
Copy link
Author

How to Use next_tag in the Parent Workflow

With the recent changes, the next_tag is now exposed as an output, making it accessible in any parent workflow that invokes this job.

Example Usage in a Parent Workflow

To utilize the next_tag output in a parent workflow, you can reference it using ${{ needs.<job_id>.outputs.next_tag }}.
Here's a sample implementation:

  deploy:
    needs: tagging
    runs-on: ubuntu-latest
    steps:
      - name: Use the Next Tag
        run: echo "Next tag is ${{ needs.tagging.outputs.next_tag }}"

Important Note:
The needs: tagging directive is crucial. So make sure to use next_tag after the tagging job completes successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants