fix #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
tag: | |
name: Create Tag | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
outputs: | |
tag: v${{ steps.get_version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: "0" | |
- name: Configure git identity | |
run: | | |
git config --global user.email "contact@raphael-catarino.fr" | |
git config --global user.name "[bot] zareix" | |
- name: Get version from package.json | |
id: get_version | |
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
- name: Remove existing tag if exists | |
run: | | |
if git rev-parse v${{ steps.get_version.outputs.version }} >/dev/null 2>&1; then | |
echo "Tag v${{ steps.get_version.outputs.version }} already exists" | |
git push --delete origin v${{ steps.get_version.outputs.version }} | |
git tag -d v${{ steps.get_version.outputs.version }} | |
fi | |
- name: Create tag | |
run: | | |
git tag -a v${{ steps.get_version.outputs.version }} -m "Version ${{ steps.get_version.outputs.version }}" | |
git push origin v${{ steps.get_version.outputs.version }} | |
release: | |
name: Create Github release | |
runs-on: ubuntu-latest | |
needs: tag | |
permissions: | |
contents: write | |
env: | |
TAG: ${{ needs.tag.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.TAG }} | |
docker-build-push: | |
name: Build and push docker image | |
needs: tag | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
env: | |
working-directory: . | |
TAG: ${{ needs.tag.outputs.tag }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install cosign | |
uses: sigstore/cosign-installer@main | |
with: | |
cosign-release: "v2.0.0-rc.0" | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into registry ${{ env.REGISTRY }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value=latest | |
type=semver,pattern={{raw}},value=${{ env.TAG }} | |
- name: Build and push Docker image for amd64 | |
id: build-and-push | |
uses: docker/build-push-action@v6 | |
with: | |
context: ${{ env.working-directory }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
platforms: linux/amd64 #,linux/arm64 |