Skip to content

Commit 507cd68

Browse files
committed
Merge branch 'develop'
2 parents 57873a0 + e3ec940 commit 507cd68

10 files changed

+112
-54
lines changed

.github/workflows/integration.yml

+13-5
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,35 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828
- uses: actions/checkout@v2
29-
- name: Generate git ref
29+
- name: Get the version
30+
id: get_version
31+
run: "echo ::set-output name=VERSION::$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')"
32+
- name: Generate git ref in environment variables
3033
run: "sed -i -E \"s|gitRef: '(.*)'|gitRef: '$GITHUB_SHA'|g\" src/environments/environment.heroku.ts"
34+
- name: Generate version in environment variables
35+
run: "sed -i -E \"s|version: '(.*)'|version: '${{ steps.get_version.outputs.VERSION }}'|g\" src/environments/environment.heroku.ts"
3136
- name: Build the Docker image
32-
run: docker build . --file Dockerfile --build-arg configuration=heroku-fr --tag docker.pkg.github.com/les-projets-cagnottes/web/web:latest
37+
run: docker build . --file Dockerfile --build-arg configuration=heroku-fr --tag docker.pkg.github.com/les-projets-cagnottes/web/web:heroku-${{ steps.get_version.outputs.VERSION }}
3338
- name: Login to Registry
3439
run: docker login docker.pkg.github.com -u thomah -p ${{secrets.GITHUB_TOKEN}}
3540
- name: Publish to Registry
36-
run: docker push docker.pkg.github.com/les-projets-cagnottes/web/web:latest
41+
run: docker push docker.pkg.github.com/les-projets-cagnottes/web/web:heroku-${{ steps.get_version.outputs.VERSION }}
3742

3843
deploy-heroku:
3944
needs: publish-docker
4045
runs-on: ubuntu-latest
4146
steps:
4247
- uses: actions/checkout@v2
4348
- uses: sjdonado/heroku@0f16401029a67519b6547af7247983640996393a
49+
- name: Get the version
50+
id: get_version
51+
run: "echo ::set-output name=VERSION::$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')"
4452
- name: Login to Registry
4553
run: docker login docker.pkg.github.com -u thomah -p ${{secrets.GITHUB_TOKEN}}
4654
- name: Pull Docker Image
47-
run: docker pull docker.pkg.github.com/les-projets-cagnottes/web/web:latest
55+
run: docker pull docker.pkg.github.com/les-projets-cagnottes/web/web:heroku-${{ steps.get_version.outputs.VERSION }}
4856
- name: Tag the image
49-
run: docker tag docker.pkg.github.com/les-projets-cagnottes/web/web:latest registry.heroku.com/les-projets-cagnottes/web
57+
run: docker tag docker.pkg.github.com/les-projets-cagnottes/web/web:heroku-${{ steps.get_version.outputs.VERSION }} registry.heroku.com/les-projets-cagnottes/web
5058
- name: Get Heroku Tools
5159
run: wget -qO- https://toolbelt.heroku.com/install.sh | sh
5260
- name: Login to Heroku Registry

.github/workflows/pre-release.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Pre-Release
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
branches:
9+
- master
10+
11+
jobs:
12+
13+
verify-version:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
is_snapshot: ${{ steps.test_version.outputs.IS_SNAPSHOT }}
17+
version: ${{ steps.get_version.outputs.VERSION }}
18+
steps:
19+
- uses: actions/checkout@v2
20+
with:
21+
ref: '${{ github.head_ref }}'
22+
- name: Get the version
23+
id: get_version
24+
run: "echo ::set-output name=VERSION::$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')"
25+
- name: Test version
26+
id: test_version
27+
run: echo ::set-output name=IS_SNAPSHOT::$(if [[ "${{ steps.get_version.outputs.VERSION }}" == *"-SNAPSHOT" ]]; then echo "1"; else echo "0"; fi)
28+
29+
prepare-release:
30+
needs: verify-version
31+
runs-on: ubuntu-latest
32+
if: needs.verify-version.outputs.is_snapshot == 1
33+
steps:
34+
- uses: actions/checkout@v2
35+
with:
36+
ref: '${{ github.head_ref }}'
37+
- name: Get previous version
38+
id: get_previous_version
39+
run: "echo ::set-output name=VERSION::$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')"
40+
- name: Get released version
41+
id: get_released_version
42+
run: echo ::set-output name=VERSION::$(sed "s/-SNAPSHOT//g" <<<"${{ steps.get_previous_version.outputs.VERSION }}")
43+
- name: Get release
44+
id: get_release
45+
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_released_version.outputs.VERSION }};)
46+
- name: Test release existence
47+
run: if [[ "${{ steps.get_release.outputs.RELEASE_HTTP_CODE }}" -eq "200" ]]; then exit 1; else exit 0; fi
48+
- name: Replace version without snapshot
49+
run: "sed -i 's/\"version\": \"${{ steps.get_previous_version.outputs.VERSION }}\"/\"version\": \"${{ steps.get_released_version.outputs.VERSION }}\"/g' package.json"
50+
- name: Generate version in environment variables
51+
run: "sed -i -E \"s|version: '(.*)'|version: '${{ steps.get_released_version.outputs.VERSION }}'|g\" src/environments/environment.prod.ts"
52+
- name: Use Node.js ${{ matrix.node-version }}
53+
uses: actions/setup-node@v1
54+
with:
55+
node-version: ${{ matrix.node-version }}
56+
- run: npm i
57+
- name: Push released version
58+
run: git config user.email "${{ secrets.GIT_CONFIG_EMAIL }}" && git config user.name "${{ secrets.GIT_CONFIG_NAME }}"
59+
- run: git add package.json
60+
- run: git add package-lock.json
61+
- run: git commit -m "Release '${{ steps.get_released_version.outputs.VERSION }}'"
62+
- run: git push origin HEAD:${{ github.head_ref }}

.github/workflows/release.yml

+27-44
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,22 @@ jobs:
1010
verify-version:
1111
runs-on: ubuntu-latest
1212
outputs:
13-
is_snapshot: ${{ steps.test_version.outputs.IS_SNAPSHOT }}
1413
version: ${{ steps.get_version.outputs.VERSION }}
1514
steps:
1615
- uses: actions/checkout@v2
1716
- name: Get the version
1817
id: get_version
1918
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
5326

5427
build:
55-
needs: prepare-release
28+
needs: verify-version
5629
runs-on: ubuntu-latest
5730
strategy:
5831
matrix:
@@ -67,45 +40,55 @@ jobs:
6740
- run: npm run build --if-present
6841

6942
release:
70-
needs: [prepare-release, build]
43+
needs: [verify-version, build]
7144
runs-on: ubuntu-latest
7245
steps:
7346
- 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 }}
7451
- name: Create Release
7552
uses: actions/create-release@v1
7653
env:
7754
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7855
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 }}
8160
draft: false
8261
prerelease: false
8362

8463
publish-docker:
85-
needs: [prepare-release, release]
64+
needs: [verify-version, release]
8665
runs-on: ubuntu-latest
8766
steps:
8867
- uses: actions/checkout@v2
8968
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"
9172
- 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 }}
9374
- name: Login to Registry
9475
run: docker login docker.pkg.github.com -u thomah -p ${{secrets.GITHUB_TOKEN}}
9576
- 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 }}
9778

9879
deploy-production:
99-
needs: [prepare-release, release]
80+
needs: [verify-version, release]
10081
runs-on: ubuntu-latest
10182
steps:
10283
- uses: actions/checkout@v2
10384
with:
104-
ref: '${{ needs.prepare-release.outputs.version }}'
85+
ref: '${{ needs.verify-version.outputs.version }}'
10586
- name: Use Node.js 10.x
10687
uses: actions/setup-node@v1
10788
with:
10889
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"
10992
- run: npm ci
11093
- run: npm run build -- --configuration production-fr --output-path=dist
11194
- name: Get the version

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "les-projets-cagnottes",
3-
"version": "0.5.2",
3+
"version": "0.5.3",
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",

src/app/app/lesprojetscagnottes.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
<footer class="main-footer">
134134
Wanna improve this app ? Please, <b>join the team <a href="https://github.com/les-projets-cagnottes"> on Github </a> !</b>
135135
<div class="float-right d-none d-sm-inline-block">
136-
<b>UI Version </b><a href="https://github.com/les-projets-cagnottes/web/tree/{{ gitRef }}">0.5.0-SNAPSHOT{{ gitShortRef }}</a>
136+
<b>Version </b><a href="https://github.com/les-projets-cagnottes/web/tree/{{ gitRef }}">0{{ version }}{{ gitShortRef }}</a>
137137
</div>
138138
</footer>
139139

src/app/app/lesprojetscagnottes.component.ts

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export class LesProjetsCagnottesComponent implements OnInit, OnDestroy {
1515

1616
gitRef: string = '';
1717
gitShortRef: string = '';
18+
version: string = '';
1819
currentOrganization: Organization = new Organization();
1920
currentOrganizationSubscription: Subscription;
2021
currentUser: User = new User();
@@ -26,6 +27,7 @@ export class LesProjetsCagnottesComponent implements OnInit, OnDestroy {
2627
private organizationService: OrganizationService
2728
) {
2829
this.gitRef = environment.gitRef;
30+
this.version = environment.version;
2931
if(this.gitRef.length === 40) this.gitShortRef = ' @' + this.gitRef.substring(0, 7);
3032
this.currentUser.avatarUrl = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
3133
this.currentUserSubscription = this.authenticationService.currentUser.subscribe(user => {

src/environments/environment.heroku.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ export const environment = {
22
production: true,
33
apiUrl: 'https://les-projets-cagnottes-api.herokuapp.com/api',
44
slackClientId: '744027460679.730717520259',
5-
gitRef: 'master'
5+
version: 'develop',
6+
gitRef: 'develop'
67
};

src/environments/environment.prod.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ export const environment = {
22
production: true,
33
apiUrl: 'https://les-projets-cagnottes.fr/api',
44
slackClientId: '115462816321.761013265159',
5-
gitRef: 'stable'
5+
version: 'master',
6+
gitRef: 'master'
67
};

src/environments/environment.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const environment = {
66
production: false,
77
apiUrl: 'http://localhost:8080/api',
88
slackClientId: '744027460679.730717520259',
9+
version: 'head',
910
gitRef: 'head'
1011
};
1112

0 commit comments

Comments
 (0)