chore(DVIZ-24): fix github actions tag generations #16
Workflow file for this run
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: Build and Release | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- release/* | |
permissions: | |
contents: write | |
pull-requests: write | |
packages: write | |
jobs: | |
prepare-a-release: | |
runs-on: ubuntu-latest | |
outputs: | |
new_version: ${{ steps.tag_version.outputs.new_version }} | |
new_tag: ${{ steps.tag_version.outputs.new_tag }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'corretto' | |
cache: 'maven' | |
- name: Cache Maven packages | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.m2/repository | |
!~/.m2/repository/org/devgateway/tcdi | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Configure Git user | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "Timothy Mugo Gachengo" | |
- name: Build the Maven project | |
run: | | |
mvn package -DskipTests=true -Dcheckstyle.skip \ | |
&& mkdir -p forms/target/deps \ | |
&& cd forms/target/deps \ | |
&& jar -xf ../*.jar | |
- name: Generate a changelog | |
uses: orhun/git-cliff-action@v3 | |
id: changelog | |
with: | |
config: cliff.toml | |
env: | |
OUTPUT: CHANGELOG.md | |
GITHUB_REPO: ${{ github.repository }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate Tag | |
id: tag_version | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
release_branches: 'master,main,release/*' | |
tag_prefix: 'v' | |
dry_run: 'true' | |
custom_tag: '1.0.0' | |
build-and-push-docker-image: | |
needs: prepare-a-release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ vars.DOCKER_REGISTRY }} | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
cache-from: type=gha, scope=data-viz-admin | |
cache-to: type=gha, scope=data-viz-admin | |
context: . | |
push: true | |
build-args: | | |
VERSION=${{ needs.release-and-tag.outputs.new_version }} | |
TAG=${{ needs.release-and-tag.outputs.new_version }} | |
tags: | | |
${{ vars.DOCKER_REGISTRY }}/data-viz-admin:latest | |
${{ vars.DOCKER_REGISTRY }}/data-viz-admin:v${{ needs.release-and-tag.outputs.new_version }} | |
release-on-github: | |
needs: build-and-push-docker-image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ needs.release-and-tag.outputs.new_tag }} | |
files: forms/target/deps/*.jar | |
body_path: CHANGELOG.md | |
draft: false | |
prerelease: false | |
make_latest: 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |