release #18
This file contains 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
name: release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: | | |
New version for the release | |
If the version is in format <major>.<minor>.<patch> a new release is emitted. | |
Otherwise for other format ( for example <major>.<minor>.<patch>-beta.1 ), a prerelease is emitted. | |
default: "1.0.0" | |
required: true | |
type: string | |
description: | |
description: "Version description" | |
type: string | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-qemu-action@v2 | |
- uses: docker/setup-buildx-action@v2 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Bump version | |
run: bun run scripts/bump-version.ts ${{ github.event.inputs.version }} | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and publish the docker image | |
uses: docker/build-push-action@v4 | |
id: docker-build | |
with: | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository }}:${{ github.sha }} | |
ghcr.io/${{ github.repository }}:${{ github.event.inputs.version }} | |
- name: Update action.yml to point to the newly created docker image | |
run: | | |
NEW_IMAGE="ghcr.io/${{ github.repository }}@${{ steps.docker-build.outputs.digest }}" | |
sed -i 's|image: "docker://.*"|image: "docker://'$NEW_IMAGE'"|' action.yml | |
- name: Push new build, tag version and push | |
id: push-tags | |
run: | | |
VERSION=${{ github.event.inputs.version }} | |
git config --global user.email "[email protected]" | |
git config --global user.name "CherninLab release bot" | |
git add action.yml | |
git add package.json | |
git commit -m "📦 $VERSION" | |
git tag v$VERSION | |
git push origin main --tags | |
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
git tag v$( echo $VERSION | cut -d. -f 1-1 ) | |
git tag v$( echo $VERSION | cut -d. -f 1-2 ) | |
git push origin --tags --force | |
echo "prerelease=false" >> $GITHUB_OUTPUT | |
else | |
echo "prerelease=true" >> $GITHUB_OUTPUT | |
fi | |
- uses: ncipollo/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag: v${{ github.event.inputs.version }} | |
body: ${{ github.event.inputs.description }} | |
prerelease: ${{ steps.push-tags.outputs.prerelease }} |