66e39f15b2
Signed-off-by: Gato <cedric@goutailler-olivier.fr>
73 lines
2.7 KiB
YAML
73 lines
2.7 KiB
YAML
name: Release
|
|
|
|
on:
|
|
release:
|
|
types: [published]
|
|
|
|
jobs:
|
|
docker:
|
|
name: Build & push Docker image
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://github.com/actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: https://github.com/docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea container registry
|
|
uses: https://github.com/docker/login-action@v3
|
|
with:
|
|
registry: git.goutailler-olivier.com
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.RELEASE_TOKEN }}
|
|
|
|
- name: Set lowercase repo name
|
|
id: repo
|
|
run: echo "name=$(echo '${{ gitea.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
|
|
|
|
- name: Bump version in package.json
|
|
run: |
|
|
VERSION=$(echo "${{ gitea.ref_name }}" | sed 's/^v//')
|
|
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/" package.json
|
|
|
|
- name: Build and push
|
|
uses: https://github.com/docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
git.goutailler-olivier.com/${{ steps.repo.outputs.name }}:${{ gitea.ref_name }}
|
|
git.goutailler-olivier.com/${{ steps.repo.outputs.name }}:latest
|
|
cache-from: type=registry,ref=git.goutailler-olivier.com/${{ steps.repo.outputs.name }}:cache
|
|
cache-to: type=registry,ref=git.goutailler-olivier.com/${{ steps.repo.outputs.name }}:cache,mode=max
|
|
|
|
- name: Trigger production deployment
|
|
run: |
|
|
curl -sf -X POST \
|
|
-H "Authorization: Bearer ${{ secrets.WATCHTOWER_TOKEN }}" \
|
|
https://watchtower.goutailler-olivier.com/v1/update
|
|
|
|
- name: Merge release to main
|
|
run: |
|
|
git config user.name "Gitea Actions"
|
|
git config user.email "actions@gitea"
|
|
git remote set-url origin https://${{ gitea.actor }}:${{ secrets.RELEASE_TOKEN }}@git.goutailler-olivier.com/${{ gitea.repository }}.git
|
|
git fetch origin main
|
|
git checkout main
|
|
git merge --no-ff ${{ gitea.ref_name }} -m "chore: release ${{ gitea.ref_name }}"
|
|
git push origin main
|
|
|
|
- name: Bump version to next SNAPSHOT on develop
|
|
run: |
|
|
VERSION=$(echo "${{ gitea.ref_name }}" | sed 's/^v//')
|
|
IFS='.' read -r major minor patch <<< "$VERSION"
|
|
NEXT_VERSION="$major.$minor.$((patch + 1))-SNAPSHOT"
|
|
git fetch origin develop
|
|
git checkout develop
|
|
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$NEXT_VERSION\"/" package.json
|
|
git add package.json
|
|
git commit -m "chore: bump version to $NEXT_VERSION"
|
|
git push origin develop
|