Skip to content

Release

Release #22

Workflow file for this run

---
name: Release
on:
workflow_dispatch:
inputs:
title:
description: "Release title (blank for tag)"
required: false
jobs:
release:
runs-on: ubuntu-latest
environment: deployment
name: Publish and Release
steps:
- name: Source checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Install node 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
registry-url: "https://registry.npmjs.org"
- name: Configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Setup qemu
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ vars.PLATFORMS }}
- name: Setup docker buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Install project modules
run: npm ci --production
- name: Decide new version
id: bump
run: echo "version=$(node src/cli.js | jq '.next')" >> "$GITHUB_OUTPUT"
- name: Update package version
run: npm version ${{ steps.bump.outputs.version }} --no-git-tag-version
- name: Push new version
run: |
git add package.json package-lock.json
git commit -m "build: updated package with ${{ steps.bump.outputs.version }} [skip ci]"
git push
- name: Set a release name
id: release_name
uses: actions/github-script@v7
with:
script: |
var retval = ${{ steps.bump.outputs.version }}
if ('${{ github.event.inputs.title }}') {
retval = retval.concat(' - ${{ github.event.inputs.title }}')
}
core.setOutput('value', retval)
- name: Create a release
uses: actions/github-script@v7
with:
script: |
const repo_name = context.payload.repository.full_name
const response = await github.request('POST /repos/' + repo_name + '/releases', {
tag_name: '${{ steps.bump.outputs.version }}',
name: '${{ steps.release_name.outputs.value }}',
generate_release_notes: true
})
core.setOutput('html_url', response.data.html_url)
- name: Publish package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish
- name: Extract meta for image
id: meta
uses: docker/metadata-action@v5
with:
images: tomerfi/version-bumper
labels: |
org.opencontainers.image.version=${{ steps.bump.outputs.version }}
- name: Push image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: ${{ vars.PLATFORMS }}
tags: |
tomerfi/version-bumper:latest
tomerfi/version-bumper:${{ steps.bump.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
labels: ${{ steps.meta.outputs.labels }}
- name: Update image description on docker hub
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: tomerfi/version-bumper