Skip to content

Commit 0e64fc7

Browse files
Merge pull request #30 from devgateway/develop
Merge #develop into main
2 parents b58fa67 + 6df9cf6 commit 0e64fc7

1 file changed

Lines changed: 110 additions & 0 deletions

File tree

.github/workflows/pre-release.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Generate a Pre-Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- develop
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
packages: write
13+
14+
jobs:
15+
prepare-a-release:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
new_version: ${{ steps.tag_version.outputs.new_version }}
19+
new_tag: ${{ steps.tag_version.outputs.new_tag }}
20+
current_date: ${{ steps.current_date.outputs.current_date }}
21+
steps:
22+
- name: Checkout Repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: '0'
26+
27+
- name: Configure Git user
28+
run: |
29+
git config user.email "tmugo@developmentgateway.org"
30+
git config user.name "Timothy Mugo Gachengo"
31+
32+
- name: Get Current Date And Time
33+
id: current_date
34+
run: echo "current_date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
35+
36+
- name: Generate Tag
37+
id: tag_version
38+
uses: mathieudutour/github-tag-action@v6.2
39+
with:
40+
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
tag_prefix: 'v'
42+
pre_release_branches: 'develop'
43+
append_to_pre_release_tag: 'snapshot-${{steps.current_date.outputs.current_date}}'
44+
dry_run: 'true'
45+
46+
build-and-push-docker-image:
47+
needs: prepare-a-release
48+
runs-on: ubuntu-latest
49+
outputs:
50+
new_version: ${{ needs.prepare-a-release.outputs.new_version }}
51+
new_tag: ${{ needs.prepare-a-release.outputs.new_tag }}
52+
current_date: ${{ needs.prepare-a-release.outputs.current_date }}
53+
steps:
54+
- name: Checkout Repository
55+
uses: actions/checkout@v4
56+
57+
- name: Set up QEMU
58+
uses: docker/setup-qemu-action@v3
59+
with:
60+
platforms: linux/amd64,linux/arm64
61+
62+
- name: Set up Docker Buildx
63+
uses: docker/setup-buildx-action@v2
64+
65+
- name: Login to Docker Registry
66+
uses: docker/login-action@v3
67+
with:
68+
registry: ${{ vars.DOCKER_REGISTRY }}
69+
username: ${{ secrets.DOCKER_USERNAME }}
70+
password: ${{ secrets.DOCKER_PASSWORD }}
71+
72+
- name: Build and push Docker image
73+
uses: docker/build-push-action@v6
74+
with:
75+
platforms: linux/amd64,linux/arm64
76+
cache-from: type=gha, scope=data-viz-admin
77+
cache-to: type=gha, scope=data-viz-admin
78+
context: .
79+
push: true
80+
build-args: |
81+
VERSION=${{ needs.prepare-a-release.outputs.new_version }}
82+
TAG=${{ needs.prepare-a-release.outputs.new_tag }}
83+
tags: |
84+
${{ vars.DOCKER_REGISTRY }}/data-viz-admin:v${{ needs.prepare-a-release.outputs.new_version }}
85+
86+
release-on-github:
87+
needs: build-and-push-docker-image
88+
runs-on: ubuntu-latest
89+
steps:
90+
- name: Checkout Repository
91+
uses: actions/checkout@v4
92+
93+
- name: Set up JDK
94+
uses: actions/setup-java@v4
95+
with:
96+
java-version: '21'
97+
distribution: 'corretto'
98+
cache: 'maven'
99+
100+
- name: Create Release
101+
id: create_release
102+
uses: softprops/action-gh-release@v2
103+
with:
104+
tag_name: ${{ needs.build-and-push-docker-image.outputs.new_tag }}
105+
generate_release_notes: true
106+
draft: false
107+
prerelease: true
108+
make_latest: 'true'
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)