Skip to content
Merged
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
18 changes: 15 additions & 3 deletions .github/workflows/bump-gitstream-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@ on:
workflow_dispatch:
inputs:
version:
description: Version number (ex. "2.1.20")
description: Version number (ex. "2.1.133")
required: true
default: 2.1.20
default: 2.1.133
ticket:
description: LINBEE-XXXX ticket number
default: LINBEE-8514
required: false
description:
description: Add a description for this version
required: false
auto-deploy:
description: Add label "auto-deploy" to PR
required: false
type: boolean
default: true

jobs:
publish_pr:
name: Publish PR
Expand All @@ -27,6 +33,12 @@ jobs:
run: |
echo "VERSION=${{ inputs.version }}" >> "$GITHUB_ENV"
echo "BRANCH_NAME=${{ inputs.ticket }}-bump-gitstream-core-to-${{ inputs.version }}" >> "$GITHUB_ENV"
echo "LABEL_ARG=" >> "$GITHUB_ENV"

- name: Set auto-deploy label
if: inputs.auto-deploy
run: |
echo "LABEL_ARG=--label auto-deploy" >> "$GITHUB_ENV"

- name: Init npmrc
run: |
Expand All @@ -53,4 +65,4 @@ jobs:
--title "Bump \`@linearb/gitstream-core\` to \`${{ env.VERSION }}\`" \
--body-file pr_description.txt \
--head ${{ env.BRANCH_NAME }} \
--reviewer ${{ github.actor }}
--reviewer ${{ github.actor }} ${{ env.LABEL_ARG }}
54 changes: 54 additions & 0 deletions .github/workflows/create-tag-on-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Create Tag on merge

on:
workflow_dispatch:
push:
branches:
- develop
paths:
- src/**
- dist/**
- package*.json

jobs:
create-tag:
runs-on: ubuntu-24.04
timeout-minutes: 15

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Create and push new tag
run: npm run create-tag

- name: Get latest commit
id: get-commit
run: echo "LAST_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV

- name: Check for associated pull request and auto-deploy label
id: should-deploy
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const commit_sha = '${{ env.LAST_SHA }}';
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ commit_sha, owner, repo });
if (prs?.length > 0) {
const pull_number = prs[0].number;
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number });
return pr.labels.some(label => label.name.includes('auto-deploy'));
}
return false;

- name: Create GitHub Release & Deploy
if: steps.should-deploy.outputs.result == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create $NEW_TAG --generate-notes
git checkout $NEW_TAG
npm run update-v2-tag
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"lint": "eslint . -c ./.github/linters/.eslintrc.yml",
"package": "ncc build --minify src/index.ts -o dist --license licenses.txt",
"test": "jest",
"all": "npm run format:write && npm run lint && npm run test && npm run package"
"all": "npm run format:write && npm run lint && npm run test && npm run package",
"create-tag": "./scripts/tag-version.sh",
"update-v2-tag": "git tag v2 -f && git push origin v2 -f"
},
"license": "Apache-2.0",
"dependencies": {
Expand Down
25 changes: 25 additions & 0 deletions scripts/tag-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

git fetch --tags

# Get the latest tag
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)

# Check if the latest tag starts with 'v' and remove it
if [[ $latest_tag == v* ]]; then
latest_tag=${latest_tag:1}
fi

# Split the latest tag into an array
IFS='.' read -r -a version_parts <<< "$latest_tag"

# Bump the patch version
new_tag="${version_parts[0]}.${version_parts[1]}.$((version_parts[2] + 1))"

# Create and push the new tag
git tag $new_tag
git push origin $new_tag
echo "new_tag=$new_tag"

echo "new_tag=$new_tag" >> $GITHUB_OUTPUT
echo "NEW_TAG=$new_tag" >> $GITHUB_ENV