-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (125 loc) · 4.17 KB
/
pipeline.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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Devops AClimate API
on:
push:
branches: [ "stage" ]
tags:
- 'v*'
permissions:
contents: read
env:
GEOSERVER_USERNAME: ${{secrets.GEOSERVER_USERNAME}}
GEOSERVER_PASSWORD: ${{secrets.GEOSERVER_PASSWORD}}
jobs:
# ------- START TEST PROCCESS -------- #
TestModules:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Create environment
run: |
python -m venv env
- name: Active environment
run: |
source env/bin/activate
- name: Install dependencies
run: |
pip install -r ./requirements.txt
- name: Create credentials file
run: |
echo "GEOSERVER_USER=${{env.GEOSERVER_USERNAME}}" > geo_config.txt
echo "GEOSERVER_PASSWORD=${{env.GEOSERVER_PASSWORD}}" >> geo_config.txt
- name: Run Tests
run: |
python -m unittest discover -s ./src/test/ -p 'test_*.py'
# ------- END TEST PROCCESS -------- #
# ------- START MERGE PROCCESS -------- #
MergeMainModules:
needs: [TestModules]
name: Merge Stage with Main
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Merge stage -> main
uses: devmasx/merge-branch@master
with:
type: now
head_to_merge: ${{ github.ref }}
target_branch: main
github_token: ${{ github.token }}
# ------- END MERGE PROCCESS -------- #
# ------- START RELEASE PROCCESS -------- #
PostRelease:
needs: MergeMainModules
name: Create Release
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
# API Zip
- name: Zip artifact for deployment
run: zip releaseModules.zip ./src/* -r
# Upload Artifacts
- name: Upload API artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: API
path: releaseModules.zip
# Generate Tagname
- name: Generate Tagname for release
id: taggerDryRun
uses: anothrNick/github-tag-action@1.61.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DRY_RUN: true
DEFAULT_BUMP: patch
RELEASE_BRANCHES : stage,main
BRANCH_HISTORY: last
# Create release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ steps.taggerDryRun.outputs.new_tag }}
release_name: Release ${{ steps.taggerDryRun.outputs.new_tag }}
#body_path: ./body.md
body: ${{ github.event.head_commit.message }}
draft: false
prerelease: false
# Upload Assets to release
- name: Upload Release Asset Modules
id: upload-modules-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./releaseModules.zip
asset_name: releaseModules.zip
asset_content_type: application/zip
# update version setup.py
- name: Checkout code
uses: actions/checkout@v3
with:
ref: main
- name: Update version
run: |
sed -i "s/version='.*'/version='${{ steps.taggerDryRun.outputs.new_tag }}'/" setup.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update version to ${{ steps.taggerDryRun.outputs.new_tag }}"
# ------- END RELEASE PROCCESS -------- #