Skip to content

Commit cd361e4

Browse files
committed
Update release pipeline script
1 parent 39cc58e commit cd361e4

File tree

2 files changed

+49
-25
lines changed

2 files changed

+49
-25
lines changed

.github/release-drafter.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ replacers:
3838
- search: '/(?:and)?(,)?(\s)*@github-actions(?:\[bot\])?,?/g'
3939
replace: ""
4040
template: |
41+
[![DockerHub Release](https://img.shields.io/docker/v/mltooling/ml-workspace/$RESOLVED_VERSION?label=docker%20version&color=blue)](https://hub.docker.com/repository/docker/mltooling/ml-workspace) [![DockerHub Image Size](https://img.shields.io/docker/image-size/mltooling/ml-workspace/$RESOLVED_VERSION?label=docker%20image%20size&color=blue)](https://hub.docker.com/repository/docker/mltooling/ml-workspace)
42+
4143
$CHANGES
4244
4345
## 👥 Contributors

.github/workflows/release-pipeline.yml

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,81 @@ 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

1718
jobs:
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 }}"
34+
# Set host ip to env variable to be uside within container actions
3135
- name: set-host-ip
3236
run: echo "::set-env name=_HOST_IP::$(hostname -I | cut -d ' ' -f 1)"
33-
- if: ${{ env.GITHUB_TOKEN && env.VERSION }}
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 != '' }}
3445
name: create-release-branch
3546
uses: peterjgrainger/[email protected]
3647
env:
3748
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3849
with:
3950
branch: "${{ env.BRANCH_PREFIX }}${{ env.VERSION }}"
40-
- if: ${{ ! env.GITHUB_TOKEN }}
51+
- if: ${{ ! (env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '') }}
4152
uses: actions/checkout@v2
42-
- if: ${{ env.GITHUB_TOKEN }}
53+
- if: ${{ env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
4354
uses: actions/checkout@v2
4455
with:
4556
fetch-depth: 0
4657
ref: ${{ env.BRANCH_PREFIX }}${{ env.VERSION }}
58+
token: ${{ env.GITHUB_TOKEN }}
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4761
- name: run-component-builds
4862
uses: ./.github/actions/build-environment
4963
with:
5064
build_args: --make --force --version=${{ env.VERSION }}
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5167
- name: run-linting-and-style-checks
5268
uses: ./.github/actions/build-environment
5369
with:
5470
build_args: --check --force --version=${{ env.VERSION }}
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5573
- name: run-component-tests
5674
uses: ./.github/actions/build-environment
5775
with:
5876
build_args: --test --force --test-marker=slow --version=${{ env.VERSION }}
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5979
- name: release-components
6080
uses: ./.github/actions/build-environment
6181
env:
6282
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6383
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
6484
PYPI_REPOSITORY: ${{ secrets.PYPI_REPOSITORY }}
6585
with:
66-
build_args: --release --force --version=${{ env.VERSION }}
86+
build_args: --release --force --version=${{ env.VERSION }}
6787
container_registry_url: ${{ secrets.CONTAINER_REGISTRY_URL }}
6888
container_registry_username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
6989
container_registry_password: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
70-
# Optional: do automatic changes to source code artefacts required for release
71-
- if: ${{ env.GITHUB_TOKEN }}
90+
- if: ${{ env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
7291
name: update-repository
7392
uses: stefanzweifel/git-auto-commit-action@v4
7493
with:
@@ -77,32 +96,35 @@ jobs:
7796
commit_user_email: [email protected]
7897
commit_message: Apply automatic release changes for v${{ env.VERSION }}
7998
tagging_message: v${{ env.VERSION }}
80-
- if: ${{ env.GITHUB_TOKEN }}
81-
name: pull-request
82-
uses: repo-sync/pull-request@v2
83-
with:
84-
source_branch: ${{ env.BRANCH_PREFIX }}${{ env.VERSION }}
85-
destination_branch: "main"
86-
pr_title: Finalize release for version ${{ env.VERSION }}
87-
pr_body: "Automated pull request for release version ${{ env.VERSION }}"
88-
pr_draft: false
89-
pr_allow_empty: true
90-
pr_label: "skip changelog"
91-
# only works if it exist: pr_milestone: v${{ env.VERSION }}
92-
github_token: ${{ secrets.GITHUB_TOKEN }}
99+
- if: ${{ env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
100+
name: create-pull-request
101+
shell: bash
102+
run: |
103+
# Stops script execution if a command has an error
104+
set -e
105+
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.2
106+
# TODO: Milestone link currently does not work with closed milestones: ${{ env.PR_MILESTONE_LINK }} (problem with hub cli)
107+
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
108+
rm bin/hub
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93111
# Fix of release drafter to allow different events to trigger the release
94-
- if: ${{ env.GITHUB_TOKEN }}
112+
# TODO: currently does not work with act
113+
- if: ${{ env.GITHUB_ACTOR == 'nektos/act' && env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
114+
name: no-relese-drafter-support
115+
run: echo "The release drafter currently does not work with act, please create the release from the Github UI."
116+
- if: ${{ env.GITHUB_ACTOR != 'nektos/act' && env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
95117
name: checkout-fixed-release-drafter
96118
uses: actions/checkout@v2
97119
with:
98120
repository: ml-tooling/release-drafter
99-
path: ./.github/actions/release-drafter
100-
- if: ${{ env.GITHUB_TOKEN }}
121+
path: ./.git/cloned-actions/release-drafter
122+
- if: ${{ env.GITHUB_ACTOR != 'nektos/act' && env.GITHUB_TOKEN != null && env.GITHUB_TOKEN != '' }}
101123
name: create-release-draft
102-
uses: ./.github/actions/release-drafter
124+
uses: ./.git/cloned-actions/release-drafter
103125
with:
104126
version: ${{ env.VERSION }}
105127
tag: v${{ env.VERSION }}
106128
env:
107129
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108-
# Optional: upload release assets via actions/upload-release-asset@v1
130+
# Optional: upload release assets via actions/upload-release-asset@v1 and via upload_url from release drafter

0 commit comments

Comments
 (0)