-
Notifications
You must be signed in to change notification settings - Fork 1
75 lines (65 loc) · 2.21 KB
/
Copy pathrelease.yml
File metadata and controls
75 lines (65 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Release
on:
workflow_run:
workflows: ["CI"]
branches: [main]
types: [completed]
workflow_dispatch:
jobs:
release:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extrair versao
id: ver
run: |
VER=$(node -p "require('./package.json').version")
echo "version=$VER" >> $GITHUB_OUTPUT
- name: Lowercase image name
id: img
run: echo "name=$(echo 'ghcr.io/${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Verificar se tag ja existe
id: check
run: |
git fetch --tags
if git rev-parse "v${{ steps.ver.outputs.version }}" >/dev/null 2>&1; then
echo "new=false" >> $GITHUB_OUTPUT
echo "Tag v${{ steps.ver.outputs.version }} ja existe — sem release."
else
echo "new=true" >> $GITHUB_OUTPUT
echo "Nova versao: v${{ steps.ver.outputs.version }}"
fi
- uses: docker/setup-buildx-action@v3
if: steps.check.outputs.new == 'true'
- name: Login no GHCR
if: steps.check.outputs.new == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build e push Docker
if: steps.check.outputs.new == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
push: true
tags: |
${{ steps.img.outputs.name }}:${{ steps.ver.outputs.version }}
${{ steps.img.outputs.name }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Criar GitHub Release
if: steps.check.outputs.new == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.ver.outputs.version }}
name: v${{ steps.ver.outputs.version }}
generate_release_notes: true