portfolio/.gitea/workflows/release.yaml

62 lines
1.9 KiB
YAML

name: Build and Release
run-name: ${{ gitea.actor }} is building on ${{ gitea.repository }} 🚀
on:
workflow_dispatch:
env:
DOCKER_HUB_NAMESPACE: christiangoeschel
DOCKER_HUB_REPO: portfolio
jobs:
setup-version-build-publish:
name: Setup, Build, and Publish
runs-on: ubuntu-latest
outputs:
version_tag: ${{ steps.versioning.outputs.VERSION_TAG }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup act_runner git identity
run: |
git config --global user.email "act_runner@foo.bar"
git config --global user.name "act_runner"
- name: Install git-cliff
run: |
chmod +x ./install-cliff.sh
./install-cliff.sh
working-directory: ./scripts
- id: versioning
name: Bump version
run: |
echo "VERSION_TAG=$(/usr/local/bin/git-cliff --bumped-version 2>/dev/null | tr -d 'v')" >> "$GITHUB_OUTPUT"
echo "New version: ${{ steps.versioning.outputs.VERSION_TAG }}"
- name: Generate CHANGELOG
run: |
/usr/local/bin/git-cliff --bump -o CHANGELOG.md
git add CHANGELOG.md
- name: Login to Docker Hub
run: |
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u ${{ vars.DOCKER_HUB_USERNAME }} --password-stdin
- name: Build image
run: |
docker build -t ${DOCKER_HUB_NAMESPACE}/${DOCKER_HUB_REPO}:${VERSION} .
docker push ${DOCKER_HUB_NAMESPACE}/${DOCKER_HUB_REPO}:${VERSION}
env:
VERSION: ${{ steps.versioning.outputs.VERSION_TAG }}
- name: Publish CHANGELOG and push new tag to 'main'
run: |
git commit -m "ci: Release $(/usr/local/bin/git-cliff --bumped-version 2>/dev/null) and update CHANGELOG"
git tag $(/usr/local/bin/git-cliff --bumped-version)
git push origin main
git push --tags