generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 8
161 lines (141 loc) · 5.67 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: 'release'
on:
push:
branches:
- 'releases/*'
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check if tag already exists
run: |
# Get version from package.json (head is needed because this also returns "version" npm script line)
sed -n '/version/s/,*\r*$//p' package.json | cut -d ':' -f2,3 | sed -e 's/^ "//' -e 's/"$//' | head -n 1 > app_version.tmp
cat app_version.tmp | cut -d. -f1 > major_version.tmp
export VERSION_TAG="v$(cat app_version.tmp)"
echo "package_version=$(cat app_version.tmp)" >> $GITHUB_ENV
echo "major_version=$(cat major_version.tmp)" >> $GITHUB_ENV
# Check if tag already exists
if [ $(git tag -l "$VERSION_TAG") ]; then
echo "Tag already exists, please increment version to create release"
echo "create_release=no" >> $GITHUB_ENV
else
echo "create_release=yes" >> $GITHUB_ENV
fi
- name: Docker meta Release
if: ${{ env.create_release == 'yes' }}
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
boringdownload/jira-integration
ghcr.io/rohit-gohri/jira-ci-cd-integration
# registry.gitlab.com/rohit-gohri/jira-ci-cd-integration
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=semver,pattern={{version}},value=v${{ env.package_version }}
type=semver,pattern=v{{major}},value=v${{ env.package_version }}
type=sha
- name: Docker meta Alpha
if: ${{ env.create_release == 'no' }}
id: meta-latest
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
boringdownload/jira-integration
ghcr.io/rohit-gohri/jira-ci-cd-integration
# registry.gitlab.com/rohit-gohri/jira-ci-cd-integration
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=alpha
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: 🛂 Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: 🛂 Log in to the Github Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# - name: 🛂 Log in to the Gitlab Container registry
# uses: docker/login-action@v1
# with:
# registry: registry.gitlab.com
# username: ${{ secrets.GITLAB_USERNAME }}
# password: ${{ secrets.GITLAB_TOKEN }}
- name: 🔨🚀 Build and push Release
if: ${{ env.create_release == 'yes' }}
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: 🔨🚀 Build and push Alpha
if: ${{ env.create_release == 'no' }}
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.meta-latest.outputs.tags }}
labels: ${{ steps.meta-latest.outputs.labels }}
action:
runs-on: ubuntu-latest
needs: docker
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.DRONE_USER_TOKEN }}
- name: Check if tag already exists
run: |
# Get version from package.json (head is needed because this also returns "version" npm script line)
sed -n '/version/s/,*\r*$//p' package.json | cut -d ':' -f2,3 | sed -e 's/^ "//' -e 's/"$//' | head -n 1 > app_version.tmp
cat app_version.tmp | cut -d. -f1 > major_version.tmp
export VERSION_TAG="v$(cat app_version.tmp)"
echo "package_version=$(cat app_version.tmp)" >> $GITHUB_ENV
echo "major_version=$(cat major_version.tmp)" >> $GITHUB_ENV
# Check if tag already exists
if [ $(git tag -l "$VERSION_TAG") ]; then
echo "Tag already exists, please increment version to create release"
echo "create_release=no" >> $GITHUB_ENV
else
echo "create_release=yes" >> $GITHUB_ENV
fi
- name: 🚀 Release
uses: softprops/action-gh-release@v1
if: ${{ env.create_release == 'yes' }}
with:
tag_name: v${{ env.package_version }}
target_commitish: ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.DRONE_USER_TOKEN }}
- name: 🚀 Tag Major Version
if: ${{ env.create_release == 'yes' }}
run: |
git config user.name rohit-drone
git config user.email [email protected]
git tag -fa v${{ env.major_version }} -m "Update v${{ env.major_version }} tag"
git push origin v${{ env.major_version }} --force