Repository navigation
Release #3
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: | |
| 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 |