-
Notifications
You must be signed in to change notification settings - Fork 1
INTER-2266: Improve move tag workflow #168
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
+112
−21
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bc17eb4
chore: improve move tag workflow
erayaydin 7062145
fix: add default and required to major version
erayaydin be71e80
fix: add permissions for the move workflow
erayaydin baf7a1a
refactor: use show-ref instead of tag list
erayaydin fde94d0
fix: use merge-base for main reachability check
erayaydin 823dfcb
fix: peel annotated tags and quote inputs
erayaydin 76b027c
fix: use fully ref in reachability check
erayaydin 2057ee5
docs: add CONTRIBUTING.md and releasing to README
erayaydin 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
Some comments aren't visible on the classic Files Changed page.
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 |
|---|---|---|
| @@ -1,32 +1,47 @@ | ||
| name: Move v1 Tag | ||
| name: Update Main Version | ||
| run-name: Move ${{ github.event.inputs.major_version }} to ${{ github.event.inputs.target }} | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| target: | ||
| description: The tag to use | ||
| required: true | ||
| major_version: | ||
| type: choice | ||
| description: The major version to update | ||
| required: true | ||
| default: v1 | ||
| options: | ||
| - v1 | ||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
|
Copilot marked this conversation as resolved.
|
||
| move-tag: | ||
| tag: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v7 | ||
|
|
||
| - name: Check branch | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Git config | ||
| run: | | ||
| if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then | ||
| echo "This action can only be run on the main branch." | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| - name: Validate target is a tag | ||
| run: | | ||
| if ! git show-ref --tags --verify --quiet "refs/tags/${{ github.event.inputs.target }}"; then | ||
| echo "Error: '${{ github.event.inputs.target }}' is not a valid tag." | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Set up Git user | ||
| - name: Validate target tag is reachable from main | ||
| run: | | ||
| git config user.name "semantic-release-bot" | ||
| git config user.email "semantic-release-bot@martynus.net" | ||
|
|
||
| - name: Move v1 tag to the latest commit in main | ||
| run: | | ||
| git fetch --tags | ||
| git tag -d v1 || echo "v1 tag not found, continuing" | ||
| git push origin :refs/tags/v1 || echo "v1 tag not found in origin, continuing" | ||
| git tag v1 | ||
| git push origin v1 | ||
| commit=$(git rev-list -1 "refs/tags/${{ github.event.inputs.target }}^{}") | ||
| if ! git merge-base --is-ancestor "$commit" origin/main; then | ||
| echo "Error: Tag '${{ github.event.inputs.target }}' points to a commit not reachable from main." | ||
| exit 1 | ||
| fi | ||
| - name: Tag new target | ||
| run: git tag -f "${{ github.event.inputs.major_version }}" "${{ github.event.inputs.target }}^{}" | ||
|
erayaydin marked this conversation as resolved.
|
||
| - name: Push new tag | ||
| run: git push origin "${{ github.event.inputs.major_version }}" --force | ||
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,69 @@ | ||
| # Contributing | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - [Node.js](https://nodejs.org/) (LTS) | ||
| - [pnpm](https://pnpm.io/) v9 | ||
|
|
||
| ## Setup | ||
|
|
||
| ```sh | ||
| pnpm install | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| ### Project structure | ||
|
|
||
| This is a **pnpm workspace monorepo** with two types of artifacts: | ||
|
|
||
| - **npm packages** in `packages/` - shared configs for ESLint, Prettier, TypeScript, commitlint, and changesets | ||
| - **GitHub Actions** in `.github/actions/` - custom composite and TypeScript actions | ||
| - **Reusable workflows** in `.github/workflows/` - shared CI/CD workflows consumed by other repositories | ||
|
|
||
| ### Scripts | ||
|
|
||
| | Command | Description | | ||
| |---|---| | ||
| | `pnpm run build` | Build all npm packages | | ||
| | `pnpm run build:actions` | Bundle TypeScript GitHub Actions into `dist/` using `@vercel/ncc` | | ||
| | `pnpm run test` | Run tests with Jest | | ||
| | `pnpm run test:coverage` | Run tests with coverage report | | ||
| | `pnpm run lint` | Run ESLint | | ||
| | `pnpm run lint:fix` | Run ESLint with autofix | | ||
|
|
||
| ### Commit conventions | ||
|
|
||
| This repository uses [conventional commits](https://www.conventionalcommits.org/) enforced by commitlint via a husky `commit-msg` hook. | ||
|
|
||
| ### Building GitHub Actions | ||
|
|
||
| If you modify a TypeScript GitHub Action under `.github/actions/`, you **must** run `pnpm run build:actions` and commit the resulting `dist/` files. The `check-dist` CI check will fail if the committed dist is out of sync with the source. | ||
|
|
||
| ## Releasing | ||
|
|
||
| This repository contains two types of publishable artifacts, each with its own release process. | ||
|
|
||
| ### npm packages | ||
|
|
||
| npm packages are released automatically via [changesets](https://github.com/changesets/changesets). To release a new version: | ||
|
|
||
| 1. Create a changeset in your PR by running `pnpm exec changeset`. | ||
| 2. Merge the PR to `main`. | ||
| 3. Changesets will open a "Version Packages" PR. Merging that PR publishes the updated packages to npm. | ||
|
|
||
| ### GitHub Actions and reusable workflows | ||
|
|
||
| Actions and reusable workflows are consumed by other repositories via git tags (e.g. `@v1`). To release a new version: | ||
|
|
||
| 1. Merge your PR with the action/workflow changes to `main`. | ||
| 2. Create and push a new semver tag from the merge commit: | ||
| ```sh | ||
| git tag v1.x.y | ||
| git push origin v1.x.y | ||
| ``` | ||
| 3. Go to **Actions > Update Main Version** and run the workflow with: | ||
| - **target**: the tag you just pushed (e.g. `v1.x.y`) | ||
| - **major_version**: `v1` | ||
|
|
||
| This moves the `v1` tag to point at your new release, so all consumers referencing `@v1` pick up the change. |
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
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.
Uh oh!
There was an error while loading. Please reload this page.