-
Notifications
You must be signed in to change notification settings - Fork 235
feat | LAY-917 Added an action to create a new tag. Added scripts for… #30
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # This workflow creates and pushes a release tag using the push-release-tag.sh script. | ||
| # It can be triggered manually and will prompt for confirmation before creating the tag. | ||
|
|
||
| name: Create Release Tag | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| dry_run: | ||
| description: "Run in dry-run mode (show what would be done without actually creating/pushing the tag)" | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| confirm_release: | ||
| description: "Type 'YES' to confirm you want to create and push the release tag" | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| check-branch: | ||
| runs-on: ubuntu-latest | ||
| environment: production | ||
| steps: | ||
| - name: Check if running on release branch | ||
| run: | | ||
| if [ "${{ github.ref }}" != "refs/heads/release" ]; then | ||
| echo "Error: This workflow can only be run from the 'release' branch." | ||
| echo "Current branch: ${{ github.ref }}" | ||
| echo "Please switch to the 'release' branch and try again." | ||
| exit 1 | ||
| fi | ||
| echo "Running on release branch - proceeding with workflow." | ||
|
|
||
| create-release-tag: | ||
| runs-on: ubuntu-latest | ||
| needs: check-branch | ||
| environment: production | ||
| if: github.ref == 'refs/heads/release' | ||
|
|
||
| permissions: | ||
| contents: write # Required to create and push tags | ||
|
|
||
| steps: | ||
| - name: Validate confirmation | ||
| if: github.event.inputs.confirm_release != 'YES' && github.event.inputs.dry_run != 'true' | ||
| run: | | ||
| echo "Error: You must type 'YES' in the confirm_release input to proceed with creating a release tag." | ||
| echo "Received: '${{ github.event.inputs.confirm_release }}'" | ||
| exit 1 | ||
|
|
||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # Fetch all history and tags | ||
|
|
||
| - name: Make scripts executable | ||
| run: | | ||
| chmod +x scripts/push_release_tag.sh | ||
| chmod +x scripts/get_version.sh | ||
|
|
||
| - name: Configure Git | ||
| run: | | ||
| git config --global user.name "github-actions[bot]" | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Run push-release-tag script (dry-run) | ||
| if: github.event.inputs.dry_run == 'true' | ||
| run: | | ||
| echo "Running in dry-run mode..." | ||
| make push-release-tag DRY_RUN=--dry-run | ||
|
|
||
| - name: Run push-release-tag script | ||
| if: github.event.inputs.dry_run != 'true' | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| echo "Creating and pushing release tag..." | ||
| # Override the interactive confirmation since we already confirmed via workflow input | ||
| echo "YES" | make push-release-tag | ||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| ROOT_DIR=$(git rev-parse --show-toplevel) | ||
|
|
||
| # Parse command line arguments | ||
| DRY_RUN=false | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --dry-run) | ||
| DRY_RUN=true | ||
| shift | ||
| ;; | ||
| *) | ||
| echo "Unknown option: $1" | ||
| echo "Usage: $0 [--dry-run]" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| git fetch --tags --prune | ||
|
|
||
| REPO_URL="https://github.com/LayerLens/atlas-python" | ||
| # e.g. v1.0.0, v1.0.1, etc. | ||
| TAG_PREFIX="v" | ||
| COMMIT=$(git rev-parse --short HEAD) | ||
| VERSION=$(bash "$ROOT_DIR/scripts/get_version.sh") | ||
| TAG="${TAG_PREFIX}${VERSION}" | ||
|
|
||
| if git rev-parse "$TAG" >/dev/null 2>&1; then | ||
| echo "Error: Tag $TAG already exists" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Find the most recent version tag | ||
| LAST_RELEASE=$(git tag -l "${TAG_PREFIX}*" --sort=-v:refname | head -n 1) | ||
|
|
||
| echo "================================================" | ||
| echo " Atlas Python SDK Release" | ||
| echo "================================================" | ||
| echo "version: ${TAG}" | ||
| echo "commit: ${COMMIT}" | ||
| echo "code: ${REPO_URL}/commit/${COMMIT}" | ||
| echo "changeset: ${REPO_URL}/compare/${LAST_RELEASE}...${COMMIT}" | ||
|
|
||
| if [ "$DRY_RUN" = true ]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "" | ||
| echo "Are you ready to release version ${VERSION}? Type 'YES' to continue:" | ||
| read -r CONFIRMATION | ||
|
|
||
| if [ "$CONFIRMATION" != "YES" ]; then | ||
| echo "Release cancelled." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Create and push the tag | ||
| echo "" | ||
| echo "Creating and pushing tag ${TAG}" | ||
| echo "" | ||
|
|
||
| git tag "$TAG" "$COMMIT" | ||
| git push origin "$TAG" | ||
|
|
||
| echo "" | ||
| echo "Tag ${TAG} has been created and pushed to origin." | ||
| echo "" |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #!/bin/bash | ||
| # Validate release requirements | ||
| # - Checks if the tag matches semantic versioning convention (v{major}.{minor}.{patch} with optional suffix) | ||
| # - Checks if the tag matches the version in the package | ||
| # - Ensures we're releasing from the release branch | ||
|
|
||
| set -e | ||
|
|
||
| # Get the tag from the first command line argument | ||
| if [ $# -eq 0 ]; then | ||
| echo "ERROR: Release tag argument not provided" | ||
| echo "Usage: $0 <release-tag>" | ||
| exit 1 | ||
| fi | ||
|
|
||
| ROOT_DIR=$(git rev-parse --show-toplevel) | ||
|
|
||
| # Fetch the latest tags to ensure we're up to date | ||
| git fetch --tags --prune --force | ||
|
|
||
| TAG=$1 | ||
|
|
||
| # Check if tag follows semantic versioning pattern (v{major}.{minor}.{patch} with optional suffix) | ||
| if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then | ||
| echo "ERROR: Tag must follow semantic versioning pattern (v{major}.{minor}.{patch} with optional suffix)" | ||
| echo "Examples: v1.0.0, v2.1.3, v1.0.0-beta, v1.0.0-rc.1" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Extract version without the 'v' prefix | ||
| VERSION=${TAG#v} | ||
|
|
||
| PACKAGE_VERSION=$(bash "$ROOT_DIR/scripts/get_version.sh") | ||
|
|
||
| # Check if the tag version matches the package version | ||
| if [ "$VERSION" != "$PACKAGE_VERSION" ]; then | ||
| echo "ERROR: Tag version ($VERSION) does not match package version ($PACKAGE_VERSION)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
| if [ "$CURRENT_BRANCH" != "release" ]; then | ||
| # If we're in detached HEAD state (which is likely in GitHub Actions with a tag), | ||
| # we need to check if the tag is on the release branch | ||
| if ! git rev-parse "$TAG" &>/dev/null; then | ||
| echo "ERROR: Tag $TAG does not exist in the repository" | ||
| exit 1 | ||
| fi | ||
|
|
||
| TAG_COMMIT=$(git rev-parse "$TAG") | ||
|
|
||
| # Ensure we have release branch history | ||
| git fetch origin release --depth=1000 | ||
|
|
||
| # Check if tag is on release branch | ||
| if ! git merge-base --is-ancestor "$TAG_COMMIT" origin/release; then | ||
| echo "ERROR: Tag $TAG is not on the release branch" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| # All checks passed | ||
| exit 0 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should configure the enviornment in this section so we don't specify it at each step.
The two env we have are development and production. The production env should be used on the release branch.