Release DevWorkspace Operator #103
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
name: Release DevWorkspace Operator | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'version in format v0.y.z' | |
required: true | |
prerelease: | |
description: If true, prerelease will be done, otherwise release | |
required: true | |
forceRecreateTags: | |
description: If true, tags will be recreated. Use with caution | |
required: false | |
default: 'false' | |
dryrun: | |
description: If true, dry-run will be executed - no result are pushed | |
required: false | |
default: 'false' | |
jobs: | |
release: | |
env: | |
OPERATOR_SDK_VERSION: v1.8.0 | |
OPM_VERSION: v1.19.5 | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.20.10 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Clone source code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Check existing tags | |
run: | | |
set +e | |
RECREATE_TAGS=${{ github.event.inputs.forceRecreateTags }} | |
VERSION=${{ github.event.inputs.version }} | |
EXISTING_TAG=$(git ls-remote --exit-code origin refs/tags/${VERSION}) | |
if [[ -n ${EXISTING_TAG} ]]; then | |
if [[ ${RECREATE_TAGS} == "true" ]]; then | |
echo "[INFO] Removing tag for ${VERSION} version. New tag will be recreated during release." | |
git push origin :$VERSION | |
else | |
echo "[ERROR] Cannot proceed with release - tag ${EXISTING_TAG} already exists." | |
exit 1 | |
fi | |
else | |
echo "[INFO] No existing tags detected for $VERSION" | |
fi | |
- name: Cache Operator SDK ${{ env.OPERATOR_SDK_VERSION }} | |
uses: actions/cache@v3 | |
id: cache-operator-sdk | |
with: | |
path: ~/cache | |
key: operator-sdk-${{ env.OPERATOR_SDK_VERSION }} | |
- name: Download Operator SDK ${{ env.OPERATOR_SDK_VERSION }} | |
if: steps.cache-operator-sdk.outputs.cache-hit != 'true' | |
run: | | |
mkdir -p ~/cache | |
wget https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk_linux_amd64 -O ~/cache/operator-sdk-${OPERATOR_SDK_VERSION} > /dev/null -O ~/cache/operator-sdk-${OPERATOR_SDK_VERSION} > /dev/null | |
chmod +x ~/cache/operator-sdk-${OPERATOR_SDK_VERSION} | |
- name: Install Operator SDK ${{ env.OPERATOR_SDK_VERSION }} | |
run: | | |
mkdir -p ~/bin | |
cp ~/cache/operator-sdk-${OPERATOR_SDK_VERSION} ~/bin/operator-sdk | |
echo "$HOME/bin" >> $GITHUB_PATH | |
- name: Cache OPM ${{ env.OPM_VERSION }} | |
uses: actions/cache@v3 | |
id: cache-opm | |
with: | |
path: ~/cache | |
key: opm-${{ env.OPM_VERSION }} | |
- name: Download OPM ${{ env.OPM_VERSION }} | |
if: steps.cache-opm.outputs.cache-hit != 'true' | |
run: | | |
mkdir -p ~/cache | |
wget https://github.com/operator-framework/operator-registry/releases/download/${OPM_VERSION}/linux-amd64-opm -O ~/cache/opm${OPM_VERSION} > /dev/null | |
#${OPM_VERSION} is used in binary name to prevent caching after upgrading | |
chmod +x ~/cache/opm${OPM_VERSION} | |
- name: Install OPM ${{ env.OPM_VERSION }} | |
run: | | |
mkdir -p ~/bin | |
cp ~/cache/opm${OPM_VERSION} ~/bin/opm | |
echo "$HOME/bin" >> $GITHUB_PATH | |
- name: Login to quay.io | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
registry: quay.io | |
- name: Set up yq | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.6 | |
- name: Setup yq | |
run: | | |
python -m pip install --upgrade pip | |
pip install yq | |
cd ${GITHUB_WORKSPACE} | |
- name: Release | |
run: | | |
# Need to grab goimports otherwise formatting after this step will fail | |
# PR checks. | |
go install golang.org/x/tools/cmd/goimports@latest | |
git config --global user.name "Angel Misevski" | |
git config --global user.email "[email protected]" | |
export GITHUB_TOKEN=${{ secrets.CHE_INCUBATOR_BOT_GITHUB_TOKEN }} | |
RELEASE_COMMAND="./make-release.sh --version ${{ github.event.inputs.version }}" | |
if [[ "${{ github.event.inputs.prerelease }}" == "true" ]]; then | |
RELEASE_COMMAND="$RELEASE_COMMAND --prerelease" | |
else | |
RELEASE_COMMAND="$RELEASE_COMMAND --release" | |
fi | |
if [[ "${{ github.event.inputs.dry-run }}" == "true" ]]; then | |
RELEASE_COMMAND="$RELEASE_COMMAND --dry-run" | |
fi | |
$RELEASE_COMMAND | |
- name: Create failure MM message | |
if: ${{ failure() }} | |
run: | | |
echo "{\"text\":\":no_entry_sign: DevWorkspace Operator ${{ github.event.inputs.version }} release has failed: https://github.com/devfile/devworkspace-operator/actions/workflows/release.yml\"}" > mattermost.json | |
- name: Create success MM message | |
run: | | |
echo "{\"text\":\":white_check_mark: DevWorkspace Operator ${{ github.event.inputs.version }} has been released: https://quay.io/devfile/devworkspace-operator:${{ github.event.inputs.version }}\"}" > mattermost.json | |
- name: Send MM message | |
if: ${{ github.event.inputs.dryrun != true && github.event.inputs.prerelease == false && (success() || failure()) }} | |
uses: mattermost/[email protected] | |
env: | |
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} | |
MATTERMOST_CHANNEL: eclipse-che-releases | |
MATTERMOST_USERNAME: che-bot |