1
+ name : New release
2
+
3
+ on :
4
+ push :
5
+ tags :
6
+ - ' *'
7
+
8
+ jobs :
9
+ build-and-push :
10
+ runs-on : ubuntu-latest
11
+
12
+ steps :
13
+ - name : Checkout repository
14
+ uses : actions/checkout@v4
15
+
16
+ - name : Log in to Docker Hub
17
+ uses : docker/login-action@v3
18
+ with :
19
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
20
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
21
+
22
+ - name : Log in to GitHub Container Registry
23
+ uses : docker/login-action@v3
24
+ with :
25
+ registry : ghcr.io
26
+ username : ${{ github.actor }}
27
+ password : ${{ secrets.GITHUB_TOKEN }}
28
+
29
+ - name : Extract tag name
30
+ id : tag
31
+ run : echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
32
+
33
+ - name : Build and push Docker image to Docker Hub
34
+ uses : docker/build-push-action@v5
35
+ with :
36
+ push : true
37
+ tags : |
38
+ ${{ secrets.DOCKERHUB_USERNAME }}/jam:${{ env.TAG }}
39
+ ${{ secrets.DOCKERHUB_USERNAME }}/jam:latest
40
+
41
+ - name : Build and push Docker image to GitHub Container Registry
42
+ uses : docker/build-push-action@v5
43
+ with :
44
+ push : true
45
+ tags : |
46
+ ghcr.io/${{ github.repository_owner }}/jam:${{ env.TAG }}
47
+ ghcr.io/${{ github.repository_owner }}/jam:latest
48
+
49
+ - name : Generate changelog from last tag
50
+ id : changelog
51
+ run : |
52
+ PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ || echo "")
53
+ if [ -n "$PREV_TAG" ]; then
54
+ LOG=$(git log $PREV_TAG..HEAD --pretty=format:"- %s")
55
+ else
56
+ LOG=$(git log --pretty=format:"- %s")
57
+ fi
58
+ echo "CHANGELOG<<EOF" >> $GITHUB_ENV
59
+ echo "$LOG" >> $GITHUB_ENV
60
+ echo "EOF" >> $GITHUB_ENV
61
+
62
+ - name : Create GitHub Release
63
+ uses : softprops/action-gh-release@v1
64
+ with :
65
+ tag_name : ${{ env.TAG }}
66
+ name : Release ${{ env.TAG }}
67
+ body : ${{ env.CHANGELOG }}
68
+ draft : false
69
+ prerelease : false
0 commit comments