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 "[email protected] "
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%H%M%S')" >> $GITHUB_ENV
35
+
36
+ - name : Generate Tag
37
+ id : tag_version
38
+ uses :
mathieudutour/[email protected]
39
+ with :
40
+ github_token : ${{ secrets.GITHUB_TOKEN }}
41
+ release_branches : ' develop'
42
+ tag_prefix : ' v'
43
+ pre_release_branches : ' develop' ,
44
+ append_to_pre_release_tag : ' snapshot-${{ steps.current_date.outputs.current_date }}'
45
+ dry_run : ' true'
46
+
47
+ build-and-push-docker-image :
48
+ needs : prepare-a-release
49
+ runs-on : ubuntu-latest
50
+ outputs :
51
+ new_version : ${{ needs.prepare-a-release.outputs.new_version }}
52
+ new_tag : ${{ needs.prepare-a-release.outputs.new_tag }}
53
+ current_date : ${{ needs.prepare-a-release.outputs.current_date }}
54
+ steps :
55
+ - name : Checkout Repository
56
+ uses : actions/checkout@v4
57
+
58
+ - name : Set up QEMU
59
+ uses : docker/setup-qemu-action@v3
60
+ with :
61
+ platforms : linux/amd64,linux/arm64
62
+
63
+ - name : Set up Docker Buildx
64
+ uses : docker/setup-buildx-action@v2
65
+
66
+ - name : Login to Docker Registry
67
+ uses : docker/login-action@v3
68
+ with :
69
+ registry : ${{ vars.DOCKER_REGISTRY }}
70
+ username : ${{ secrets.DOCKER_USERNAME }}
71
+ password : ${{ secrets.DOCKER_PASSWORD }}
72
+
73
+ - name : Build and push Docker image
74
+ uses : docker/build-push-action@v6
75
+ with :
76
+ platforms : linux/amd64,linux/arm64
77
+ cache-from : type=gha, scope=data-viz-admin
78
+ cache-to : type=gha, scope=data-viz-admin
79
+ context : .
80
+ push : true
81
+ build-args : |
82
+ VERSION=${{ needs.prepare-a-release.outputs.new_version }}
83
+ TAG=${{ needs.prepare-a-release.outputs.new_tag }}
84
+ tags : |
85
+ ${{ vars.DOCKER_REGISTRY }}/data-viz-admin:latest
86
+ ${{ vars.DOCKER_REGISTRY }}/data-viz-admin:v${{ needs.prepare-a-release.outputs.new_version }}
87
+
88
+ release-on-github :
89
+ needs : build-and-push-docker-image
90
+ runs-on : ubuntu-latest
91
+ steps :
92
+ - name : Checkout Repository
93
+ uses : actions/checkout@v4
94
+
95
+ - name : Set up JDK
96
+ uses : actions/setup-java@v4
97
+ with :
98
+ java-version : ' 21'
99
+ distribution : ' corretto'
100
+ cache : ' maven'
101
+
102
+ - name : Create Release
103
+ id : create_release
104
+ uses : softprops/action-gh-release@v2
105
+ with :
106
+ tag_name : ${{ needs.build-and-push-docker-image.outputs.new_tag }}
107
+ generate_release_notes : true
108
+ draft : false
109
+ prerelease : true
110
+ make_latest : ' true'
111
+ env :
112
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments