@@ -13,94 +13,120 @@ env:
1313 VERSION : ${{ secrets.VERSION }}
1414 BRANCH_PREFIX : " release/v"
1515 ACTIONS_ALLOW_UNSECURE_COMMANDS : true # TODO: only needed until act supports the new way
16+ DEFAULT_BRANCH : main
1617
1718jobs :
1819 release :
1920 runs-on : ubuntu-latest
2021 steps :
2122 - if : ${{ github.event.milestone != null && github.event.milestone.title != null }}
2223 name : set-milestone-version
23- run : echo "::set-env name=VERSION::$(sed "s/^v//" <<< "${{ github.event.milestone.title }}")"
24+ run : |
25+ echo "::set-env name=VERSION::$(sed "s/^v//" <<< "${{ github.event.milestone.title }}")"
26+ echo "::set-env name=PR_MILESTONE_LINK::-M ${{ github.event.milestone.title }}"
2427 - if : ${{ github.event.inputs != null && github.event.inputs.version != null }}
2528 name : set-input-version
2629 run : echo "::set-env name=VERSION::${{ github.event.inputs.version }}"
2730 - name : check-version
2831 run : ' if [[ ! "${{ env.VERSION }}" =~ ^([0-9]+\.[0-9]+\.[0-9]+.*)$ ]]; then echo "The version is not valid: ${{ env.VERSION }}"; exit 1; fi'
2932 - name : set-github-token
3033 run : echo "::set-env name=GITHUB_TOKEN::${{ secrets.GITHUB_TOKEN }}"
31- - if : ${{ env.GITHUB_TOKEN && env.VERSION }}
34+ # Set host ip to env variable to be uside within container actions
35+ - name : set-host-ip
36+ run : echo "::set-env name=_HOST_IP::$(hostname -I | cut -d ' ' -f 1)"
37+ # Fix git version for act if github token is provided
38+ - if : ${{ env.GITHUB_ACTOR == 'nektos/act' && env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
39+ name : install-latest-git
40+ run : |
41+ # Required for local checkout
42+ apt-get update
43+ apt-get install -y git
44+ - if : ${{ env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
3245 name : create-release-branch
3346 uses :
peterjgrainger/[email protected] 3447 env :
3548 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3649 with :
3750 branch : " ${{ env.BRANCH_PREFIX }}${{ env.VERSION }}"
38- - if : ${{ ! env.GITHUB_TOKEN }}
51+ - if : ${{ ! ( env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '') }}
3952 uses : actions/checkout@v2
40- - if : ${{ env.GITHUB_TOKEN }}
53+ - if : ${{ env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
4154 uses : actions/checkout@v2
4255 with :
4356 fetch-depth : 0
4457 ref : ${{ env.BRANCH_PREFIX }}${{ env.VERSION }}
58+ token : ${{ env.GITHUB_TOKEN }}
59+ env :
60+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4561 - name : run-component-builds
4662 uses : ./.github/actions/build-environment
4763 with :
4864 build_args : --make --force --version=${{ env.VERSION }}
65+ env :
66+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4967 - name : run-linting-and-style-checks
5068 uses : ./.github/actions/build-environment
5169 with :
5270 build_args : --check --force --version=${{ env.VERSION }}
71+ env :
72+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5373 - name : run-component-tests
5474 uses : ./.github/actions/build-environment
5575 with :
5676 build_args : --test --force --test-marker=slow --version=${{ env.VERSION }}
77+ env :
78+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5779 - name : release-components
5880 uses : ./.github/actions/build-environment
5981 env :
6082 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6183 PYPI_TOKEN : ${{ secrets.PYPI_TOKEN }}
6284 PYPI_REPOSITORY : ${{ secrets.PYPI_REPOSITORY }}
6385 with :
64- build_args : --release --force --version=${{ env.VERSION }}
86+ build_args : --release --force --version=${{ env.VERSION }}
6587 container_registry_url : ${{ secrets.CONTAINER_REGISTRY_URL }}
6688 container_registry_username : ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
6789 container_registry_password : ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
68- # Optional: do automatic changes to source code artefacts required for release
69- - if : ${{ env.GITHUB_TOKEN }}
70- name : update-repository
90+ - if : ${{ env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
91+ name : push-changes
7192 uses : stefanzweifel/git-auto-commit-action@v4
7293 with :
7394 branch : ${{ env.BRANCH_PREFIX }}${{ env.VERSION }}
7495 commit_user_name : Release Bot
7596 commit_user_email :
[email protected] 7697 commit_message : Apply automatic release changes for v${{ env.VERSION }}
7798 tagging_message : v${{ env.VERSION }}
78- - if : ${{ env.GITHUB_TOKEN }}
79- name : pull-request
80- uses : repo-sync/pull-request@v2
81- with :
82- source_branch : ${{ env.BRANCH_PREFIX }}${{ env.VERSION }}
83- destination_branch : " main"
84- pr_title : Finalize release for version ${{ env.VERSION }}
85- pr_body : " Automated pull request for release version ${{ env.VERSION }}"
86- pr_draft : false
87- pr_allow_empty : true
88- pr_label : " skip changelog"
89- # only works if it exist: pr_milestone: v${{ env.VERSION }}
90- github_token : ${{ secrets.GITHUB_TOKEN }}
99+ skip_dirty_check : true
100+ commit_options : " --allow-empty"
101+ - if : ${{ env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
102+ name : create-pull-request
103+ shell : bash
104+ run : |
105+ # Stops script execution if a command has an error
106+ set -e
107+ curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.2
108+ # TODO: Milestone link currently does not work with closed milestones: ${{ env.PR_MILESTONE_LINK }} (problem with hub cli)
109+ bin/hub pull-request -b ${{ env.DEFAULT_BRANCH }} -h ${{ env.BRANCH_PREFIX }}${{ env.VERSION }} --no-edit -m "Finalize release for version ${{ env.VERSION }}" -m "Automated pull request for release version ${{ env.VERSION }}" -l "skip changelog" || true
110+ rm bin/hub
111+ env :
112+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
91113 # Fix of release drafter to allow different events to trigger the release
92- - if : ${{ env.GITHUB_TOKEN }}
114+ # TODO: currently does not work with act
115+ - if : ${{ env.GITHUB_ACTOR == 'nektos/act' && env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
116+ name : no-relese-drafter-support
117+ run : echo "The release drafter currently does not work with act, please create the release from the Github UI."
118+ - if : ${{ env.GITHUB_ACTOR != 'nektos/act' && env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
93119 name : checkout-fixed-release-drafter
94120 uses : actions/checkout@v2
95121 with :
96122 repository : ml-tooling/release-drafter
97- path : ./.github/ actions/release-drafter
98- - if : ${{ env.GITHUB_TOKEN }}
123+ path : ./.git/cloned- actions/release-drafter
124+ - if : ${{ env.GITHUB_ACTOR != 'nektos/act' && env. GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
99125 name : create-release-draft
100- uses : ./.github/ actions/release-drafter
126+ uses : ./.git/cloned- actions/release-drafter
101127 with :
102128 version : ${{ env.VERSION }}
103129 tag : v${{ env.VERSION }}
104130 env :
105131 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
106- # Optional: upload release assets via actions/upload-release-asset@v1
132+ # Optional: upload release assets via actions/upload-release-asset@v1 and via upload_url from release drafter
0 commit comments