Skip to content

Commit

Permalink
Setup release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
joonashak committed Sep 10, 2024
1 parent 3d30d00 commit 8e53a57
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
changelog:
exclude:
labels:
- exclude from release notes
categories:
- title: Maintenance
labels:
- maintenance
- title: New Features
labels:
- new feature
- title: Improvements
labels:
- improvement
- title: Bug Fixes
labels:
- bug
- title: Other
labels:
- "*"
6 changes: 6 additions & 0 deletions .github/workflows/push-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ jobs:
tests:
name: Run tests
uses: ./.github/workflows/run-tests.yaml

release:
name: Publish image (next)
uses: ./.github/workflows/release.yaml
with:
latest: true
77 changes: 77 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Release new version

on:
workflow_call:
inputs:
latest:
description:
Release as the latest version, tagging the images with the version number found in
package.json.
default: false
type: boolean

jobs:
tags:
name: Compose version tags
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Parse semver number from package.json
run: |
PACKAGE_VERSION=$(cat package.json | jq '.version' | tr -d '"')
echo "MAJOR=$(echo $PACKAGE_VERSION | cut -d "." -f 1)" >> $GITHUB_ENV
echo "MINOR=$(echo $PACKAGE_VERSION | cut -d "." -f 2)" >> $GITHUB_ENV
echo "PATCH=$(echo $PACKAGE_VERSION | cut -d "." -f 3)" >> $GITHUB_ENV
echo $PACKAGE_VERSION
echo $MAJOR
- name: Compose semver tags
run: |
echo "MAJOR_V=$MAJOR" >> $GITHUB_ENV
echo "MINOR_V=MAJOR.MINOR" >> $GITHUB_ENV
echo "FULL_V=MAJOR.MINOR.PATCH" >> $GITHUB_ENV
- name: Compose tag list
run: echo "TAG_LIST=$MAJOR_V,$MINOR_V,$FULL_V,latest" >> $GITHUB_ENV
- name: Select correct tags
id: tags
run: if [ ${{ inputs.latest }} ]; then echo $TAG_LIST; else echo "next"; fi
outputs:
tag-list: ${{ inputs.latest && '$TAG_LIST' || 'next' }}

publish:
name: Publish image
needs:
- tags
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Testing
run: echo ${{ needs.tags.outputs.tag-list }}
# - name: Login to GHCR
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Build production image
# uses: docker/build-push-action@v5
# with:
# context: app
# tags: kaiku
# - name: Tag image with version
# if: ${{ inputs.latest }}
# run: |
# docker tag kaiku ghcr.io/funidata/kaiku:${{ steps.tags.outputs.full }}
# docker tag kaiku ghcr.io/funidata/kaiku:${{ steps.tags.outputs.minor }}
# docker tag kaiku ghcr.io/funidata/kaiku:${{ steps.tags.outputs.major }}
# docker tag kaiku ghcr.io/funidata/kaiku:latest
# - name: Tag image as experimental
# if: ${{ inputs.latest }}
# run: docker tag kaiku ghcr.io/funidata/kaiku:next
# - name: Push image to GHCR
# run: docker push --all-tags ghcr.io/funidata/kaiku

0 comments on commit 8e53a57

Please sign in to comment.