-
Notifications
You must be signed in to change notification settings - Fork 0
Conda packaging #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conda packaging #26
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0d529e8
Added resources for conda packaging
atteggiani 64371a7
Fix development environment path
atteggiani 1b415e7
Added noarch to conda build
atteggiani f649c8d
Removed replace_landsurface references in comments
atteggiani 6078550
Simplified version specification for action/checkout
atteggiani 00fb6dd
Add version sanity check
atteggiani 814ad68
Added logic to allow non-release tags to be pushed and not trigger a …
atteggiani 96e502e
Minor patch
atteggiani 31f32dc
Added checkout code steps
atteggiani 4529461
Updated version sanity check
atteggiani 969ad5e
Incorporated Jo's suggestions
atteggiani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| channels: | ||
| - accessnri | ||
| - conda-forge | ||
| - coecms | ||
| - nodefaults | ||
|
|
||
| dependencies: | ||
| - anaconda-client | ||
| - conda-build | ||
| - conda-verify | ||
| - versioneer |
This file contains hidden or 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 file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| {% set version = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True).get('version') %} | ||
| {% set project = load_file_data('../pyproject.toml', from_recipe_dir=True).get('project') %} | ||
|
|
||
| package: | ||
| name: {{ project.get('name') }} | ||
| version: "{{ version }}" | ||
|
|
||
| build: | ||
| number: 0 | ||
| noarch: python | ||
| script: "python3 -m pip install . -vv" | ||
| entry_points: | ||
| {% for name, script in project.get('scripts').items() %} | ||
| - {{ name }} = {{ script }} | ||
| {% endfor %} | ||
|
|
||
| source: | ||
| path: ../ | ||
|
|
||
| requirements: | ||
| host: | ||
| - python | ||
| - pip | ||
| - setuptools >=61.0.0 | ||
| - versioneer | ||
| run: | ||
| {% for dep in project.get('dependencies') %} | ||
| - {{ dep }} | ||
| {% endfor %} | ||
|
|
||
| test: | ||
| imports: | ||
| - umfile_utils | ||
| commands: | ||
| {% for name, script in project.get('scripts').items() %} | ||
| - {{ name }} --help | ||
| {% endfor %} | ||
|
|
||
| about: | ||
| home: {{ project.get('urls').get('Repository') }} | ||
| license: Apache Software | ||
| license_file: LICENSE | ||
| summary: {{ project.get('description') }} | ||
| license_family: Apache | ||
|
|
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| name: CD | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - '**' | ||
| env: | ||
| RELEASE_TAG_REGEX: ^[0-9]+\.[0-9]+\.[0-9]+$ | ||
|
|
||
| jobs: | ||
| check-release-tag: | ||
| name: Check release tag | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| is_release_tag: ${{ steps.check-tag.outputs.is_release_tag }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-tags: true | ||
|
|
||
| - name: Check tag | ||
| id: check-tag | ||
| run: | | ||
| is_release_tag=true | ||
| tag='${{ github.ref_name }}' | ||
| if [[ ! "$tag" =~ ${{ env.RELEASE_TAG_REGEX }} ]]; then | ||
| echo "::warning::The tag '$tag' was not recognised as a release tag (MAJOR.MINOR.PATCH format). Therefore, no release was created." | ||
| is_release_tag=false | ||
| fi | ||
| echo "is_release_tag=$is_release_tag" >> $GITHUB_OUTPUT | ||
|
|
||
| version-sanity-check: | ||
| name: Version sanity check | ||
| needs: [check-release-tag] | ||
| if: ${{ needs.check-release-tag.outputs.is_release_tag == 'true' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-tags: true | ||
|
|
||
| - name: Version sanity check | ||
| run: | | ||
| # Don't allow smaller new versions or jumping versions in the MAJOR.MINOR.PATCH format | ||
| old_tag_name=$(git tag --list --sort=-version:refname | grep -E '${{ env.RELEASE_TAG_REGEX }}' | sed -n '2p') | ||
| if [ -z "$old_tag_name" ]; then | ||
| echo "No previous version found. Skipping version sanity check." | ||
| exit 0 | ||
| fi | ||
| new_tag_name='${{ github.ref_name }}' | ||
| read -r old_major old_minor old_patch <<< $(echo $old_tag_name | tr '.' ' ') | ||
| read -r new_major new_minor new_patch <<< $(echo $new_tag_name | tr '.' ' ') | ||
| error_msg="Version tag inconsistent!\nVersion '$new_tag_name' cannot come after version '$new_tag_name' (latest released version)." | ||
|
jo-basevi marked this conversation as resolved.
|
||
| # Check MAJOR | ||
| # - New major version cannot be smaller than previous | ||
| # - Major version can only be incremented by 1 at a time | ||
| if (( new_major < old_major || new_major > old_major + 1 )); then | ||
| echo -e "$msg" | ||
| exit 1 | ||
| fi | ||
| # Check MINOR | ||
| # - New minor version cannot be smaller than previous if major version is same | ||
| # - New minor version can only be 0 if major version is incremented | ||
| # - New minor version can only be incremented by 1 at a time | ||
| if (( (new_major == old_major && new_minor < old_minor) || (new_major > old_major && new_minor != 0) || (new_minor > old_minor + 1) )); then | ||
| echo -e "$msg" | ||
| exit 1 | ||
| fi | ||
| # Check PATCH | ||
| # - New patch version must be bigger than previous if minor version is same | ||
| # - New patch version can only be 0 if minor version is incremented | ||
| # - New patch version can only be incremented by 1 at a time | ||
| if (( (new_minor == old_minor && new_patch <= old_patch) || (new_minor > old_minor && new_patch != 0) || (new_patch > old_patch + 1) )); then | ||
| echo -e "$msg" | ||
| exit 1 | ||
| fi | ||
|
|
||
| get-package-name: | ||
| name: Get package name | ||
| needs: [check-release-tag] | ||
| if: ${{ needs.check-release-tag.outputs.is_release_tag == 'true' }} | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| package-name: ${{ steps.get-package-name.outputs.package-name }} | ||
| steps: | ||
| - name: Checkout source | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-tags: true | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Get name | ||
| id: get-package-name | ||
| run: | | ||
| echo "package-name=$(yq '.project.name' pyproject.toml)" >> $GITHUB_OUTPUT | ||
|
|
||
| release-conda-package: | ||
| name: Build with conda and release | ||
| runs-on: ubuntu-latest | ||
| needs: [check-release-tag, version-sanity-check, get-package-name] | ||
| if: ${{ needs.check-release-tag.outputs.is_release_tag == 'true' }} | ||
| env: | ||
| BUILD_FOLDER: ${{github.workspace}}/build | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Checkout source | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-tags: true | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set package path | ||
| id: set-package-path | ||
| run: | | ||
| echo "package-path=${{env.BUILD_FOLDER}}/noarch/*${{vars.PACKAGE_FORMAT}}" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Setup conda build environment | ||
| uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4 | ||
| with: | ||
| miniconda-version: "latest" | ||
| python-version: ${{ vars.PY_VERSION }} | ||
| environment-file: .conda/env_build.yml | ||
| auto-activate-base: false | ||
| auto-update-conda: false | ||
| show-channel-urls: true | ||
|
|
||
| - name: Build conda package | ||
| shell: bash -el {0} | ||
| run: | | ||
| conda build . --no-anaconda-upload --output-folder=${{env.BUILD_FOLDER}} -c accessnri -c conda-forge -c coecms --package-format ${{vars.PACKAGE_FORMAT}} | ||
|
|
||
| - name: Upload conda package to Anaconda.org | ||
| shell: bash -el {0} | ||
| run: | | ||
| anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload --user ${{ secrets.ANACONDA_USER_NAME }} ${{steps.set-package-path.outputs.package-path}} | ||
|
jo-basevi marked this conversation as resolved.
|
||
|
|
||
| - name: Create Release | ||
| uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 #v2.0.8 | ||
| with: | ||
| tag_name: ${{ github.ref_name }} | ||
| name: ${{needs.get-package-name.outputs.package-name}} ${{ github.ref_name }} | ||
| generate_release_notes: true | ||
| fail_on_unmatched_files: true | ||
| files: | | ||
| ${{steps.set-package-path.outputs.package-path}} | ||
|
|
||
| cleanup-tag-on-failure: | ||
| name: Cleanup tag | ||
| needs: [check-release-tag, version-sanity-check, get-package-name, release-conda-package] | ||
| # Run this job if the tag is a release tag and any of the previous jobs failed (and don't skip if any of the needed jobs is skipped) | ||
| if: ${{ always() && failure() && needs.check-release-tag.outputs.is_release_tag == 'true' }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-tags: true | ||
|
|
||
| - name: Delete tag | ||
| run: | | ||
| git push origin :${{ github.ref }} | ||
| echo "A job in the current workflow failed. Tag '${{ github.ref_name }}' was deleted." | ||
|
|
||
This file contains hidden or 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 file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.