Merge pull request #77 from CIAT-DAPA/develop #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 Resampling | |
on: | |
push: | |
branches: [ "stage" ] | |
tags: | |
- 'v*' | |
permissions: | |
contents: read | |
jobs: | |
# ------- START Scripts PROCCESS -------- # | |
TestScripts: | |
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: Install GDAL dependencies | |
# run: | | |
# sudo add-apt-repository -y ppa:ubuntugis/ppa | |
# sudo apt-get update -q | |
# sudo apt-get install -y libgdal-dev | |
- name: Create environment | |
run: | | |
python -m venv env | |
- name: Active environment | |
run: | | |
source env/bin/activate | |
- name: Create .cdsapirc file | |
run: | | |
echo "url: https://cds.climate.copernicus.eu/api/v2" > /home/runner/.cdsapirc | |
echo "key: ${{ secrets.CDSAPIRC_KEY }}" >> /home/runner/.cdsapirc | |
- name: Display content | |
run: cat /home/runner/.cdsapirc | |
- name: Install dependencies part 1 | |
run: | | |
pip install -r ./requirements.txt | |
pip install --upgrade pandas "dask[complete]" | |
#- name: Install GDAL Python package | |
# run: | | |
# pip install GDAL==$(gdal-config --version) --global-option=build_ext --global-option="-I/usr/include/gdal" | |
#- name: Check GDAL version | |
# run: | | |
# python -c "from osgeo import gdal; print(gdal.__version__)" | |
- name: Run Tests | |
run: | | |
python -m unittest discover -s ./test/ | |
# ------- END Scripts PROCCESS -------- # | |
# ------- START MERGE PROCCESS -------- # | |
MergeMainScripts: | |
needs: TestScripts | |
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 -------- # | |
# ------- START RELEASE PROCCESS -------- # | |
PostRelease: | |
needs: MergeMainScripts | |
name: Create Release | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: '0' | |
# Scripts Zip | |
- name: Zip artifact for deployment | |
run: zip releaseScripts.zip ./src/* -r | |
# Upload Artifacts | |
- name: Upload Scripts artifact for deployment job | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Scripts | |
path: releaseScripts.zip | |
# Generate Tagname | |
- name: Generate Tagname for release | |
id: taggerDryRun | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WITH_V: true | |
DRY_RUN: true | |
DEFAULT_BUMP: patch | |
RELEASE_BRANCHES : stage,master | |
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 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: ./releaseScripts.zip | |
asset_name: releaseScripts.zip | |
asset_content_type: application/zip | |
# update version setup.py | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: master | |
- 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 -------- # |