Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/create-release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ on:
jobs:
create-tag:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.package-version.outputs.tag }}
tag-created: ${{ steps.create-tag.outputs.created }}
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -49,16 +52,28 @@ jobs:
fi

- name: Create and push tag
id: create-tag
if: steps.check-tag.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.package-version.outputs.tag }}" -m "Release ${{ steps.package-version.outputs.tag }}"
git push origin "${{ steps.package-version.outputs.tag }}"
echo "Created and pushed tag ${{ steps.package-version.outputs.tag }}"
echo "created=true" >> $GITHUB_OUTPUT

- name: Tag already exists
if: steps.check-tag.outputs.exists == 'true'
run: |
echo "Tag ${{ steps.package-version.outputs.tag }} already exists. Skipping tag creation."
echo "The release workflow may have already been triggered for this version."

trigger-release:
needs: create-tag
if: needs.create-tag.outputs.tag-created == 'true'
uses: ./.github/workflows/release.yml
permissions:
contents: write
packages: write
with:
tag: ${{ needs.create-tag.outputs.tag }}
32 changes: 25 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
push:
tags:
- 'v*' # Trigger on version tags like v1.0.0, v0.1.0, etc.
workflow_call: # Allow being triggered by other workflows
inputs:
tag:
description: 'Tag to release'
required: true
type: string

env:
REGISTRY: ghcr.io
Expand All @@ -15,10 +21,21 @@ jobs:
permissions:
contents: write
packages: write

steps:
- name: Determine tag
id: tag
run: |
if [ -n "${{ inputs.tag }}" ]; then
echo "tag=${{ inputs.tag }}" >> $GITHUB_OUTPUT
else
echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi

- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ steps.tag.outputs.tag }}

- name: Set up Node.js
uses: actions/setup-node@v4
Expand Down Expand Up @@ -47,7 +64,7 @@ jobs:
- name: Create build artifact
run: |
mkdir -p release-artifacts
tar -czf release-artifacts/odette-${{ github.ref_name }}.tar.gz \
tar -czf release-artifacts/odette-${{ steps.tag.outputs.tag }}.tar.gz \
dist/ \
views/ \
public/ \
Expand All @@ -72,9 +89,9 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }}
type=semver,pattern={{version}},value=${{ steps.tag.outputs.tag }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.tag.outputs.tag }}
type=raw,value=latest,enable=${{ !contains(steps.tag.outputs.tag, '-') }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
Expand All @@ -90,10 +107,11 @@ jobs:
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag.outputs.tag }}
files: release-artifacts/*
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
prerelease: ${{ contains(steps.tag.outputs.tag, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -103,7 +121,7 @@ jobs:
# runs-on: ubuntu-latest
# needs: build-and-release
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
#
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
Expand Down