Skip to content

Commit

Permalink
Add a CI for the release process
Browse files Browse the repository at this point in the history
  • Loading branch information
nwneisen committed Nov 3, 2023
1 parent 4bc8bc9 commit a1beef5
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 39 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/Merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs:
uses: ./.github/workflows/unit.yml
build:
uses: ./.github/workflows/build.yml
# TODO add integration tests
push-to-ghcr:
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} # if all need jobs are successful
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} # if all `needs` jobs are successful
needs: [vet, unit-test, build]
uses: ./.github/workflows/push-to-ghcr.yml
18 changes: 18 additions & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release

on:
release:
types: [prereleased]

jobs:
vet:
uses: ./.github/workflows/vet.yml
unit-test:
uses: ./.github/workflows/unit.yml
build:
uses: ./.github/workflows/build.yml
# TODO add integration tests
push-to-ghcr:
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} # if all `needs` jobs are successful
needs: [vet, unit-test, build]
uses: ./.github/workflows/push-to-ghcr.yml
105 changes: 72 additions & 33 deletions .github/workflows/push-to-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,79 @@ on:
workflow_call:

jobs:
# push-latest:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - name: Load environment
# uses: c-py/action-dotenv-to-setenv@v4
# with:
# env-file: .github/development.env

# - name: Log in to the Container registry
# uses: docker/[email protected]
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

# - name: Download artifact
# uses: actions/download-artifact@v3
# with:
# name: ${{ env.IMAGE }}
# path: /tmp

# - name: Load docker image
# working-directory: .
# run: docker load --input /tmp/${{ env.IMAGE }}.tar

# - name: Push latest image to ${{ env.REGISTRY }}
# working-directory: .
# run: make docker-push
push-latest:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Load environment
uses: c-py/action-dotenv-to-setenv@v4
with:
env-file: .github/development.env

- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.IMAGE }}
path: /tmp

- name: Load docker image
working-directory: .
run: docker load --input /tmp/${{ env.IMAGE }}.tar

- name: Push latest image to ${{ env.REGISTRY }}
working-directory: .
run: docker push ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:latest

push-semver:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Load environment
uses: c-py/action-dotenv-to-setenv@v4
with:
env-file: .github/development.env

- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.IMAGE }}
path: /tmp

- name: Load docker image
working-directory: .
run: docker load --input /tmp/${{ env.IMAGE }}.tar

- name: Push latest image to ${{ env.REGISTRY }}
working-directory: .
run: |
SEMVER=${GITHUB_REF#refs/*/}
SEMVER=${SEMVER:1}
echo ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:$SEMVER
docker tag ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:latest ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:$SEMVER
docker push ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:$SEMVER
push-dev:
if: ${{ github.event_name == 'push' || github.event_name == 'release'}}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -65,10 +105,9 @@ jobs:
run: docker load --input /tmp/${{ env.IMAGE }}.tar

- name: Push SHA image to ${{ env.REGISTRY }}
if: ${{ github.event_name == 'push' }}
working-directory: .
run: |
COMMIT_SHA=$(git rev-parse --short "$GITHUB_SHA")
echo $COMMIT_SHA
echo ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:$COMMIT_SHA
docker tag ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:latest ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:$COMMIT_SHA
docker push ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:$COMMIT_SHA
6 changes: 1 addition & 5 deletions docs/CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,4 @@ TODO: If you merge a change into main and an issue is found, you will be notifie

## Releases

A release is triggered when a pre-release is created in the github repo. This will run EVERYTHING from scratch. Starting from zero may take more time but this ensures that nothing slips by us before sending out the release. This includes any static code analysis, unit tests, integration tests, and building the binaries. If everything passes, the artifacts will uploaded to the release and the release will be ready for review before it is manually published.

## Nightlys (TBD)

Nightlys are triggered every night at 12:00 AM UTC. This will run EVERYTHING from scratch. This includes any static code analysis, unit tests, integration tests, and building the binaries.
A release is triggered when a pre-release is created in the github repo. This will run EVERYTHING from scratch. Starting from zero may take more time but this ensures that nothing slips by us before sending out the release. This includes any static code analysis, unit tests, integration tests, and building the binaries. If everything passes, the images will be pushed and the release will be ready for review before it is manually published. This process is documented in [Creating a release](docs/creating-a-release.md).
19 changes: 19 additions & 0 deletions docs/creating-a-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Creating a release

The release process is automated using github actions that trigger when a release is created on the github page.

1. Open releases on the github page
2. Create a pre-release which includes
a. A tag for the latest commit on main. Use semantic versioning with a v. `vX.Y.Z`
b. The auto generated changelog
c. Check the pre-release box
d. Publish the release
3. CI will trigger and begin the release process
a. Run through all tests (lint, unit, integration)
b. Build the release images
c. Publish the release images to
i. ghcr.io/mirantis/boundless-operator:<tag>
ii. ghcr.io/mirantis/boundless-operator:latest
iii. ghcr.io/mirantis/boundless-operator:<commit SHA>
4. Once CI finished, take a look at the images and make sure they look good
5. Change the release from pre-release to latest on the github page

0 comments on commit a1beef5

Please sign in to comment.