Skip to content

Release

Release #12

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
jobs:
test:
uses: ./.github/workflows/ci.yml
permissions:
contents: read
lint:
uses: ./.github/workflows/standard.yml
permissions:
checks: write
contents: write
release:
needs: [test, lint]
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
packages: write
attestations: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Get current version
id: current
run: |
# Get the latest tag, fallback to 0.0.0 if no tags exist
CURRENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
# Remove 'v' prefix if present
CURRENT_VERSION=${CURRENT_VERSION#v}
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Calculate new version
id: new
run: |
CURRENT="${{ steps.current.outputs.version }}"
IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT"
MAJOR=${VERSION_PARTS[0]}
MINOR=${VERSION_PARTS[1]}
PATCH=${VERSION_PARTS[2]}
case "${{ inputs.version }}" in
major)
NEW_VERSION="$((MAJOR + 1)).0.0"
;;
minor)
NEW_VERSION="${MAJOR}.$((MINOR + 1)).0"
;;
patch)
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
;;
esac
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Create and push tag
run: |
git tag -a "v${{ steps.new.outputs.version }}" -m "Release version ${{ steps.new.outputs.version }}"
git push origin "v${{ steps.new.outputs.version }}"
- name: Create release archive
run: |
# Create a clean archive without .git directory
git archive --format=zip --prefix=pat-logger-v${{ steps.new.outputs.version }}/ HEAD > pat-logger-v${{ steps.new.outputs.version }}.zip
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Forgejo Registry
uses: docker/login-action@v3
with:
registry: git.chobble.com
username: stefan
password: ${{ secrets.FORGEJO_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker images
uses: docker/build-push-action@v6
with:
push: true
tags: |
${{ vars.DOCKER_USERNAME }}/play-test:latest
${{ vars.DOCKER_USERNAME }}/play-test:v${{ steps.new.outputs.version }}
git.chobble.com/chobble/play-test:latest
git.chobble.com/chobble/play-test:v${{ steps.new.outputs.version }}
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:v${{ steps.new.outputs.version }}
cache-from: |
type=gha
type=registry,ref=${{ vars.DOCKER_USERNAME }}/play-test:buildcache
cache-to: |
type=gha,mode=max
type=registry,ref=${{ vars.DOCKER_USERNAME }}/play-test:buildcache,mode=max
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.new.outputs.version }}
name: Release ${{ steps.new.outputs.version }}
body: |
# v${{ steps.new.outputs.version }}
[Read the full changelog here](https://github.com/${{ github.repository }}/compare/v${{ steps.current.outputs.version }}...v${{ steps.new.outputs.version }})
## Docker Images
- `${{ vars.DOCKER_USERNAME }}/play-test:v${{ steps.new.outputs.version }}`
- `git.chobble.com/chobble/play-test:v${{ steps.new.outputs.version }}`
- `ghcr.io/${{ github.repository }}:v${{ steps.new.outputs.version }}`
files: |
play-test-v${{ steps.new.outputs.version }}.zip
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}