-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (162 loc) · 5.83 KB
/
main.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# 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 R API
on:
push:
branches: [ "stage" ]
tags:
- 'v*'
permissions:
contents: read
jobs:
# ------- START Scripts PROCCESS -------- #
TestScripts:
runs-on: macos-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Create geo_config
run: |
GEO_CONFIG=$(echo "${{ secrets.GEO_CONFIG }}")
echo "$GEO_CONFIG" > geo_config.txt
- name: Set up R
uses: r-lib/actions/setup-r@f57f1301a053485946083d7a45022b278929a78a
with:
r-version: "4.2"
- name: Install dependencies
run: |
install.packages("Rcpp")
install.packages('terra', repos='https://rspatial.r-universe.dev')
install.packages(c("glue", "fs", "curl", "openssl", "sp", "terra", "digest", "processx", "ps", "rlang", "sf", "testthat"), type="source")
install.packages(c("httr", "rjson", "raster", "sf", "webmockr", "testthat"))
shell: Rscript {0}
- name: Run Tests
run: |
library(raster)
library(sf)
library(testthat)
test_dir("tests");
shell: Rscript {0}
# ------- END Scripts PROCCESS -------- #
GenerateTagName:
needs: TestScripts
name: Generate TagName and Set env
runs-on: ubuntu-latest
outputs:
new_tag: ${{ steps.new_tag_step.outputs.new_tag }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Generate TagName
id: taggerDryRun
uses: anothrNick/github-tag-action@1.61.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DRY_RUN: true
DEFAULT_BUMP: patch
RELEASE_BRANCHES : stage,master
BRANCH_HISTORY: last
- name: Set env
id: new_tag_step
run: echo "new_tag=${{ steps.taggerDryRun.outputs.new_tag }}" >> $GITHUB_OUTPUT
# ------- START RELEASE PROCCESS -------- #
PostRelease:
needs: GenerateTagName
name: Create Release
runs-on: macos-latest
permissions: write-all
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Create geo_config
run: |
GEO_CONFIG=$(echo "${{ secrets.GEO_CONFIG }}")
echo "$GEO_CONFIG" > geo_config.txt
- name: Set up R
uses: r-lib/actions/setup-r@f57f1301a053485946083d7a45022b278929a78a
with:
r-version: "4.2"
- name: Install dependencies
run: |
install.packages("Rcpp")
install.packages('terra', repos='https://rspatial.r-universe.dev')
install.packages(c("glue", "fs", "curl", "openssl", "sp", "terra", "digest", "processx", "ps", "rlang", "sf", "testthat"), type="source")
install.packages(c("httr", "rjson", "raster", "sf", "devtools", "roxygen2"))
shell: Rscript {0}
- name: Update version in DESCRIPTION
run: |
version <- "${{ needs.GenerateTagName.outputs.new_tag }}"
lines <- readLines("${{ github.workspace }}/DESCRIPTION")
lines[grep("^Version:", lines)] <- paste0("Version: ", version)
writeLines(lines, "${{ github.workspace }}/DESCRIPTION")
shell: Rscript {0}
- name: Run Build
run: |
devtools::document()
devtools::build(path = "./")
shell: Rscript {0}
# Upload Artifacts
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: Upload artifact
path: aclimaterapi_${{ needs.GenerateTagName.outputs.new_tag }}.tar.gz
# Create release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ needs.GenerateTagName.outputs.new_tag }}
release_name: Release ${{ needs.GenerateTagName.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 Scripts
id: upload-scripts-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: ./aclimaterapi_${{ needs.GenerateTagName.outputs.new_tag }}.tar.gz
asset_name: aclimaterapi_${{ needs.GenerateTagName.outputs.new_tag }}.tar.gz
asset_content_type: application/gzip
- name: Commit Changes to stage branch
run: |
git checkout stage
git add man/
git add DESCRIPTION
git commit -m "GitHub Actions Update documentation"
git push origin stage
- name: Push Changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- uses: actions/checkout@v3
with:
fetch-depth: '0'
# ------- END RELEASE PROCCESS -------- #
# ------- START MERGE PROCCESS -------- #
MergeMainScripts:
needs: PostRelease
name: Merge Stage with master
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Merge stage -> master
uses: devmasx/merge-branch@master
with:
type: now
head_to_merge: ${{ github.ref }}
target_branch: master
github_token: ${{ github.token }}
# ------- END MERGE PROCCESS -------- #