Release DevWorkspace Operator #126
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@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
with: | |
go-version: 1.20.10 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 #v2.2.0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 #v2.10.0 | |
- name: Clone source code | |
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | |
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@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.0 | |
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@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.0 | |
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@465a07811f14bebb1938fbed4728c6a1ff8901fc #v2.2.0 | |
with: | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
registry: quay.io | |
- name: Set up yq | |
uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa # v4.8.0 | |
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/[email protected] | |
git config --global user.name "Andrew Obuchowicz" | |
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 |