Skip to content

Create Canary Release #39

Create Canary Release

Create Canary Release #39

Workflow file for this run

name: Create canary release
run-name: Create Canary Release
on:
push:
branches:
- develop
jobs:
lint:
if: contains(github.event.head_commit.message, 'Merge branch')
name: Check Lint of the code (try to auto-fix if possible)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'develop'
fetch-depth: 0
ssh-key: ${{ secrets.BASALT_SSH }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Dependencies
run: bun install
- name: Run Lint and try to auto-fix if possible
run: |
bun run lint || bun run fix-lint && bun run lint
if [ $? -ne 0 ]; then
echo "Linting failed even after auto-fix. Exiting..."
exit 1
fi
- name: Import GPG key
run: |
echo "${{ secrets.BASALT_GPG }}" | gpg --batch --import
git config --local user.signingkey "$(gpg --list-keys --with-colons | grep '^pub' | cut -d':' -f5 | head -n1)"
git config --local commit.gpgsign true
git config --local tag.gpgsign true
- name: Commit Changes
id: commit_changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
if git diff --name-only | grep -E '\.(js|ts|jsx|tsx|css|scss|json|md|yml|yaml)$'; then
git add .
git commit -m "style(🎨): Auto-fix lint issues"
else
echo "No lint-related changes to commit."
fi
- name: Push changes
run: |
git push origin HEAD:develop
test:
if: contains(github.event.head_commit.message, 'Merge branch')
name: Run tests
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'develop'
fetch-depth: 0
ssh-key: ${{ secrets.BASALT_SSH }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Dependencies
run: bun install
- name: Check if build
run: bun run build
- name: Run tests
run: bun run test
canary:
if: contains(github.event.head_commit.message, 'Merge branch')
name: Create Canary Release
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'develop'
fetch-depth: 0
ssh-key: ${{ secrets.BASALT_SSH }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Fetch tags
run: git fetch --tags --prune
- name: Import GPG key
run: |
echo "${{ secrets.BASALT_GPG }}" | gpg --batch --import
git config --local user.signingkey "$(gpg --list-keys --with-colons | grep '^pub' | cut -d':' -f5 | head -n1)"
git config --local commit.gpgsign true
git config --local tag.gpgsign true
- name: Configure git
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
- name: Generate Changelog and bump version
run: bunx changelogen@latest --bump --versionSuffix "canary-$(date +%Y%m%d)-$(git rev-parse --short HEAD)" --release
- name: Sign the tag manually
run: |
LATEST_TAG=$(git describe --tags --abbrev=0)
echo "Signing tag: $LATEST_TAG"
git tag -s "$LATEST_TAG" -m "Signed Canary Release $LATEST_TAG" --force
- name: Push generated tag
run: git push origin --tags HEAD:develop --force
- name: Verify tag signature
run: |
LATEST_TAG=$(git describe --tags --abbrev=0)
git tag -v "$LATEST_TAG"
- name: Extract Changelog additions
id: changelog_diff
run: |
git diff HEAD~1 --unified=0 CHANGELOG.md | grep '^+' | grep -v '++' | sed 's/^+//' > temp.md
echo "Changelog additions:"
cat temp.md
- name: Extract the latest tag
id: get_latest_tag
run: |
LATEST_TAG=$(git describe --tags --abbrev=0)
echo "Latest tag: $LATEST_TAG"
echo "tag_name=$LATEST_TAG" >> $GITHUB_ENV
- name: Create Canary Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Using tag: ${{ env.tag_name }}"
sleep 3
gh release create "${{ env.tag_name }}" \
--title "Canary Release ${{ env.tag_name }}" \
--notes "$(cat temp.md)" \
--prerelease
publish:
if: contains(github.event.head_commit.message, 'Merge branch')
name: Publish Canary Release
runs-on: ubuntu-latest
needs: canary
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'develop'
fetch-depth: 0
ssh-key: ${{ secrets.BASALT_SSH }}
- name: Pull latest changes from develop
run: |
git checkout develop
git pull origin develop --ff-only
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Install Dependencies
run: bun install
- name: Build the project
run: bun run build
- name: Publish the project
run: npm publish --access public --tag canary
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}