Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

Commit

Permalink
ci: properly create tags, rework workflows files
Browse files Browse the repository at this point in the history
  • Loading branch information
louisgrasset committed Oct 20, 2023
1 parent f1191da commit 942a470
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 30 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ name: Continuous Delivery
on:
push:
branches: [ "main" ]
# Prevent run if tag is present

jobs:
# Release workflows will handle the docker image creation when tag is present
publish-docker:
# Prevent run if tag is present
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
name: "Build & Push docker image (latest)"
runs-on: ubuntu-latest
permissions:
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/docker-release.yml

This file was deleted.

30 changes: 14 additions & 16 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.create-tag.outputs.version }}
tag: ${{ steps.create-tag.outputs.tag }}

steps:
- name: Checkout code
Expand All @@ -17,10 +18,12 @@ jobs:
- name: Create Git tag
id: create-tag
run: |
version="v$(jq -r '.version' package.json)"
git tag $version
git push origin $version
version="$(jq -r '.version' package.json)"
tag="v$version"
git tag $tag
git push origin $tag
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
github-release:
Expand All @@ -40,17 +43,15 @@ jobs:
config_file: .github/tag-changelog.cjs

- name: Create release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{needs.create-tag.outputs.version}}
release_name: Release ${{needs.create-tag.outputs.version}}
tag_name: ${{needs.create-tag.outputs.tag}}
name: Release ${{needs.create-tag.outputs.tag}}
body: ${{ steps.changelog.outputs.changes }}

release-docker:
needs:
- github-release
- create-tag
name: "Build & Release docker image (tag)"
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -81,17 +82,14 @@ jobs:
${{ github.repository }}
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
type=semver,pattern={{version}},value=${{needs.create-tag.outputs.version}}
type=semver,pattern={{major}}.{{minor}},value=${{needs.create-tag.outputs.version}}
- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:latest
${{ steps.meta.outputs.tags }}
ghcr.io/${{ steps.meta.outputs.tags }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 942a470

Please sign in to comment.