@@ -10,49 +10,22 @@ jobs:
10
10
verify-version :
11
11
runs-on : ubuntu-latest
12
12
outputs :
13
- is_snapshot : ${{ steps.test_version.outputs.IS_SNAPSHOT }}
14
13
version : ${{ steps.get_version.outputs.VERSION }}
15
14
steps :
16
15
- uses : actions/checkout@v2
17
16
- name : Get the version
18
17
id : get_version
19
18
run : " echo ::set-output name=VERSION::$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\" ,]//g' | tr -d '[[:space:]]')"
20
- - name : Test version
21
- id : test_version
22
- run : echo ::set-output name=IS_SNAPSHOT::$(if [[ "${{ steps.get_version.outputs.VERSION }}" == *"-SNAPSHOT" ]]; then echo "1"; else echo "0"; fi)
23
-
24
- prepare-release :
25
- needs : verify-version
26
- runs-on : ubuntu-latest
27
- if : needs.verify-version.outputs.is_snapshot == 1
28
- outputs :
29
- version : ${{ steps.get_released_version.outputs.VERSION }}
30
- steps :
31
- - uses : actions/checkout@v2
32
- - name : Get previous version
33
- id : get_previous_version
34
- run : " echo ::set-output name=VERSION::$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\" ,]//g' | tr -d '[[:space:]]')"
35
- - name : Get released version
36
- id : get_released_version
37
- run : echo ::set-output name=VERSION::$(sed "s/-SNAPSHOT//g" <<<"${{ steps.get_previous_version.outputs.VERSION }}")
38
- - name : Replace version without snapshot
39
- run : " sed -i 's/\" version\" : \" ${{ steps.get_previous_version.outputs.VERSION }}\" /\" version\" : \" ${{ steps.get_released_version.outputs.VERSION }}\" /g' package.json"
40
- - name : Use Node.js ${{ matrix.node-version }}
41
- uses : actions/setup-node@v1
42
- with :
43
- node-version : ${{ matrix.node-version }}
44
- - run : npm i
45
- - name : Push released version
46
- run : git config user.email "${{ secrets.GIT_CONFIG_EMAIL }}" && git config user.name "${{ secrets.GIT_CONFIG_NAME }}"
47
- - run : git add package.json
48
- - run : git add package-lock.json
49
- - run : git commit -m "Release '${{ steps.get_released_version.outputs.VERSION }}'"
50
- - run : git push origin
51
- - run : git tag ${{ steps.get_released_version.outputs.VERSION }}
52
- - run : git push --tags
19
+ - name : Test snapshot
20
+ run : if [[ "${{ steps.get_version.outputs.VERSION }}" == *"-SNAPSHOT" ]]; then exit 1; else exit 0; fi
21
+ - name : Get release
22
+ id : get_release
23
+ run : echo ::set-output name=RELEASE_HTTP_CODE::$(curl -s -o out.html -w '%{http_code}' https://github.com/les-projets-cagnottes/slack-events-catcher/releases/tag/${{ steps.get_version.outputs.VERSION }};)
24
+ - name : Test release existence
25
+ run : if [[ "${{ steps.get_release.outputs.RELEASE_HTTP_CODE }}" -eq "200" ]]; then exit 1; else exit 0; fi
53
26
54
27
build :
55
- needs : prepare-release
28
+ needs : verify-version
56
29
runs-on : ubuntu-latest
57
30
strategy :
58
31
matrix :
@@ -67,45 +40,55 @@ jobs:
67
40
- run : npm run build --if-present
68
41
69
42
release :
70
- needs : [prepare-release , build]
43
+ needs : [verify-version , build]
71
44
runs-on : ubuntu-latest
72
45
steps :
73
46
- uses : actions/checkout@v2
47
+ - name : Config Git
48
+ run : git config user.email "${{ secrets.GIT_CONFIG_EMAIL }}" && git config user.name "${{ secrets.GIT_CONFIG_NAME }}"
49
+ - run : git tag ${{ needs.verify-version.outputs.version }}
50
+ - run : git push origin ${{ needs.verify-version.outputs.version }}
74
51
- name : Create Release
75
52
uses : actions/create-release@v1
76
53
env :
77
54
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
78
55
with :
79
- tag_name : ${{ needs.prepare-release.outputs.version }}
80
- release_name : ${{ needs.prepare-release.outputs.version }}
56
+ tag_name : ${{ needs.verify-version.outputs.version }}
57
+ release_name : ${{ needs.verify-version.outputs.version }}
58
+ body : |
59
+ Release ${{ needs.verify-version.outputs.version }}
81
60
draft : false
82
61
prerelease : false
83
62
84
63
publish-docker :
85
- needs : [prepare-release , release]
64
+ needs : [verify-version , release]
86
65
runs-on : ubuntu-latest
87
66
steps :
88
67
- uses : actions/checkout@v2
89
68
with :
90
- ref : ' ${{ needs.prepare-release.outputs.version }}'
69
+ ref : ' ${{ needs.verify-version.outputs.version }}'
70
+ - name : Generate git ref in environment variables
71
+ run : " sed -i -E \" s|gitRef: '(.*)'|gitRef: '$GITHUB_SHA'|g\" src/environments/environment.heroku.ts"
91
72
- name : Build the Docker image
92
- run : docker build . --file Dockerfile --build-arg configuration=heroku-fr --tag docker.pkg.github.com/les-projets-cagnottes/web/web:latest
73
+ run : docker build . --file Dockerfile --build-arg configuration=heroku-fr --tag docker.pkg.github.com/les-projets-cagnottes/web/web:heroku-${{ needs.verify-version.outputs.version }}
93
74
- name : Login to Registry
94
75
run : docker login docker.pkg.github.com -u thomah -p ${{secrets.GITHUB_TOKEN}}
95
76
- name : Publish to Registry
96
- run : docker push docker.pkg.github.com/les-projets-cagnottes/web/web:latest
77
+ run : docker push docker.pkg.github.com/les-projets-cagnottes/web/web:heroku-${{ needs.verify-version.outputs.version }}
97
78
98
79
deploy-production :
99
- needs : [prepare-release , release]
80
+ needs : [verify-version , release]
100
81
runs-on : ubuntu-latest
101
82
steps :
102
83
- uses : actions/checkout@v2
103
84
with :
104
- ref : ' ${{ needs.prepare-release .outputs.version }}'
85
+ ref : ' ${{ needs.verify-version .outputs.version }}'
105
86
- name : Use Node.js 10.x
106
87
uses : actions/setup-node@v1
107
88
with :
108
89
node-version : 10.x
90
+ - name : Generate git ref in environment variables
91
+ run : " sed -i -E \" s|gitRef: '(.*)'|gitRef: '$GITHUB_SHA'|g\" src/environments/environment.heroku.ts"
109
92
- run : npm ci
110
93
- run : npm run build -- --configuration production-fr --output-path=dist
111
94
- name : Get the version
0 commit comments