Commit 050c2043 authored by Jon's avatar Jon
Browse files

Merge branch '7-publish-to-docker-hub' into 'development'

Resolve "Publish to Docker Hub"

See merge request !9
parents 26a2cb6d 6f8a93ee
Loading
Loading
Loading
Loading
Loading
+53 −37
Changes for .gitlab-ci.yml: 53 added lines, 37 removed lines.
Original line number Diff line number Diff line
#variables:
#    Release_TAG: Publish-$CI_COMMIT_SHORT_SHA
variables:
    CI_BRANCH: $CI_COMMIT_BRANCH


stages:
@@ -196,8 +196,11 @@ gitlab-management_package:
    before_script:
        - *PythonImageBuildModuleBefore_Script
        - git --version
        - python3 -m pip install --user --upgrade twine
    script:
        - python3 setup.py egg_info sdist bdist_wheel
    after_script:
        - python3 -m twine upload --verbose --repository-url https://gitlab.com/api/v4/projects/19099644/packages/pypi --username $LOCAL_PYPI_USER --password $LOCAL_PYPI_PASSWORD dist/*
    rules:
        - if: $CI_COMMIT_TAG
          when: never
@@ -276,8 +279,6 @@ pages:
          changes:
          - gitlab_management/*.py
          - setup.py
          - README.md
          - CONTRIBUTING.md
          when: on_success

          
@@ -345,7 +346,6 @@ gemnasium-python-dependency_scanning:
          when: never
        - if: $CI_COMMIT_BRANCH
          changes:
          - gitlab_management/*.py
          - setup.py
          - requirements.txt
          - requirements.pip
@@ -372,11 +372,11 @@ license_scanning:
          when: never
        - if: $CI_COMMIT_BRANCH
          changes:
          - gitlab_management/*.py
          - setup.py
          when: on_success
          allow_failure: false


Documentation:
  stage: validate
  image: readthedocs/build:latest
@@ -413,6 +413,7 @@ Documentation:
  **Commit:** $CI_COMMIT_SHA  
  **Module Version:** $Release_TAG   
  **PyPi Module Link (pip)** https://pypi.org/project/gitlab-management/$Release_TAG/    
  **Docker Hub:** https://hub.docker.com/r/nofusscomputing/gitlab-management   
  
  This release supercedes previous versions" --tag-name $Release_TAG

@@ -425,6 +426,8 @@ GitLab-Release:
    script:
        - Release_TAG=$(cat $CI_PROJECT_DIR/dist/version)
        - *ReleaseScript
    after_script:
        - export
    dependencies:
        - gitlab-management_package
        - Docker_Build-Alpine
@@ -435,63 +438,76 @@ GitLab-Release:
          when: never
        - if: '$CI_COMMIT_BRANCH == "master"'
          when: on_success
          allow_failure: false
        - if: '$CI_COMMIT_BRANCH == "development"'
          when: on_success
          allow_failure: false
        - if: '$CI_COMMIT_BRANCH != "master"'
          when: never
        - if: '$CI_COMMIT_BRANCH != "master" && $CI_COMMIT_BRANCH != "development"'
          when: manual
          allow_failure: true
    environment:
        name: Release-PyPi


Test_Publish:
PyPi:
    stage: publish
    image: python:3.6.9-slim
    variables:
        GIT_STRATEGY: none
    before_script:
        - python3 -m pip install --user --upgrade twine
        - pip3 download gitlab_management==$CI_COMMIT_TAG -f --pre --no-deps --index-url https://$LOCAL_PYPI_USER:$LOCAL_PYPI_PASSWORD@gitlab.com/api/v4/projects/19099644/packages/pypi/simple/ -d dist/
        - pip3 download gitlab_management==$CI_COMMIT_TAG --no-binary ":all:" -f --pre --no-deps --index-url https://$LOCAL_PYPI_USER:$LOCAL_PYPI_PASSWORD@gitlab.com/api/v4/projects/19099644/packages/pypi/simple/ -d dist/ --isolated || true
    script:
        - rm $CI_PROJECT_DIR/dist/version
        - python3 -m twine upload --verbose --username __token__ --password $NFC_TOKEN_TESTPYPI --repository testpypi dist/*
        - python3 -m twine upload --verbose --username __token__ --password $NFC_TOKEN_PYPI dist/*
    dependencies:
        - gitlab-management_package
        - Docker_Build-Alpine
        - GitLab-Release
    rules:
        - if: $CI_COMMIT_TAG
          when: never
          when: on_success
        - if: $CI_MERGE_REQUEST_IID
          when: never
        - if: '$CI_COMMIT_BRANCH == "development"'
        - if: '$CI_COMMIT_BRANCH'
          when: never
        - if: '$CI_COMMIT_BRANCH != "master"'
          changes:
          - gitlab_management/*.py
          - setup.py
          - README.md
          - CONTRIBUTING.md
          when: manual
          allow_failure: true
    environment:
        name: Release-PyPi


Publish:
Docker Hub:
    stage: publish
    image: python:3.6.9-slim
    variables:
        GIT_STRATEGY: none
    image: docker:latest
    services:
        - docker:19.03.11-dind
    before_script:
        - python3 -m pip install --user --upgrade twine
        - export
        - docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
        - docker pull $CI_REGISTRY_IMAGE/gitlab-management:$CI_COMMIT_SHA
        - docker logout $CI_REGISTRY
    script:
        - rm $CI_PROJECT_DIR/dist/version
        - python3 -m twine upload --verbose --username __token__ --password $NFC_TOKEN_PYPI dist/*
    dependencies:
        - gitlab-management_package
        - Docker_Build-Alpine
#        - Release_TAG=$(cat $CI_PROJECT_DIR/dist/version)
        - docker login docker.io -u nofusscomputing -p $NFC_DOCKERHUB_TOKEN
        - if [ "m$(echo $CI_BUILD_REF_NAME | grep rc)" == "m$CI_BUILD_REF_NAME" ]; then Branch_TAG=dev; else Branch_TAG=stable; fi
        - echo Branch tag is $Branch_TAG
        - docker image ls
        - docker image tag $CI_REGISTRY_IMAGE/gitlab-management:$CI_COMMIT_SHA nofusscomputing/gitlab-management:$CI_BUILD_TAG
        - docker image tag $CI_REGISTRY_IMAGE/gitlab-management:$CI_COMMIT_SHA nofusscomputing/gitlab-management:$Branch_TAG
        - docker image ls
        - docker push nofusscomputing/gitlab-management:$Branch_TAG
        - docker push nofusscomputing/gitlab-management:$CI_BUILD_TAG
    rules:
        - if: $CI_COMMIT_TAG
          when: never
          when: on_success
        - if: $CI_MERGE_REQUEST_IID
          when: never
        - if: '$CI_COMMIT_BRANCH == "master"'
          when: on_success
        - if: '$CI_COMMIT_BRANCH == "development"'
          when: manual
          allow_failure: true
        - if: '$CI_COMMIT_BRANCH'
          when: never
    dependencies:
        - gitlab-management_package
        - Docker_Build-Alpine
        - GitLab-Release
    tags:
        - docker
    environment:
        name: Release-DockerHub
+1 −1
Changes for .gitlab/issue_templates/Bug.md: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -34,5 +34,5 @@ logs, and code as it's tough to read otherwise.) -->

* [ ] ~Documentation, documentation changes completed *(if applicable)*

/label ~Bug ~"Documentation::Not Started"
/label ~Bug ~"documentation::not started" ~"workflow::not started"
/cc @jon_nfc
+1 −1
Changes for .gitlab/issue_templates/Feature_Proposal.md: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -23,4 +23,4 @@ Add all known Documentation Requirements in this section.
* [ ] ~Documentation, documentation changes completed *(if applicable)*


/label ~Feature ~"Documentation::Not Started"
/label ~Feature ~"documentation::not started" ~"workflow::not started"
+7 −3
Changes for .gitlab/merge_request_templates/default.md: 7 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -4,9 +4,13 @@

## Merge Request Tasks

* [ ] ~Documentation for all related issues completed as *applicable*
* [ ] ~"Code Review::Complete" and covering all versions
* [ ] ~"documentation::complete" for all related issues completed as *applicable*
* [ ] ~"code review::complete" and covering all versions
* [ ] Package version incremented
* [ ] Issue close in commit tag (*if applicable*) i.e. `fixes #{Issue Number}`
* [ ] Squash commit flag checked
* [ ] close or fixes #issuenumber added to squash commit message
   


/label ~"Code Review::Not Started" ~"Documentation::Not Started"
 No newline at end of file
/label ~"code review::not started" ~"documentation::not started"
 No newline at end of file
+13 −0
Changes for README.md: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -61,6 +61,19 @@ Group:
`Group.Labels.#.Group` can be a single string which is the name of an existing group that the user has access to as maintainer. `Group.Labels.#.Group` can also be a `list` of group names that the label will be added to.


### Docker container
further help can be found in the [documentation](https://python-gitlab-management.readthedocs.io/en/development/pages/docker.html).

The docker images have been desigend to run the module directly as a command, where you only have to specify the `CLI` arguments.

images are tagged for ease of idententification in accordance with the table below:

| Tag                |   repo branch   |  When created |
|--------------------|:---------------:|:------:|
| `{Version number}` |  Git Tag        | every git tag will create it's version |
| `dev`              |   development   |   when a merge to development branch occurs or a git tag is created on a branch not master. |
| `stable`           |     master      |    when a merge to master branch occurs |

## Issues, Feature Requests and Bugs
If an issue or bug is found within the package (i.e. exception), please [create an issue ticket](https://gitlab.com/nofusscomputing/projects/python-gitlab-management/-/issues) using the applicable issue template available at the time of ticket creation. If you would like to request a feature and are unable to contribute, [please create an issue](https://gitlab.com/nofusscomputing/projects/python-gitlab-management/-/issues) using the feature issue template.

Loading