Skip to content

Commit

Permalink
split create release pipeline into two workloads
Browse files Browse the repository at this point in the history
  • Loading branch information
pPrecel committed Dec 23, 2024
1 parent 70a9dfe commit a4bdf17
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 77 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,10 @@ jobs:
tags: ${{ steps.get_tag.outputs.TAGS }}
steps:
- name: Checkout
if: ${{ inputs.tag == '' }} # not release
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Checkout (release)
if: ${{ inputs.tag != '' }} # release
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }} # Checkout to latest branch changes
repository: ${{ github.event.pull_request.head.repo.full_name }}
- if: ${{ !startsWith(github.event_name, 'pull_request') }}
name: Get the latest tag
id: get_tag
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/create-release-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# This workflow is part of the release process and is automatically run when the .github/workflows/create-release.yaml one
# creates a tag because create-release.yaml pushes a new commit to the branch and building jobs can't resolve such a situation.
# Because of this, we run the second part of the process in a separate workflow that has its own context based on the tag created.

name: create release

on:
push:
tags-ignore:
- latest

permissions: # used by build images steps
id-token: write # This is required for requesting the JWT token
contents: write # This is required for actions/checkout and builds

jobs:
builds:
uses: ./.github/workflows/_build.yaml
with:
tag: "${{ github.ref_name }}"

create-draft:
name: Create draft release
needs: builds
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/setup-go

- name: Create draft release
id: create-draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RELEASE_ID=$(./.github/scripts/create-draft-release.sh ${{ github.ref_name }})
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
- name: Create release assets
id: create-assets
env:
IMG: "europe-docker.pkg.dev/kyma-project/prod/serverless-operator:${{ github.ref_name }}"
PULL_BASE_REF: ${{ github.ref_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ steps.create-draft.outputs.release_id }}
run: ./.github/scripts/release.sh

outputs:
release_id: ${{ steps.create-draft.outputs.release_id }}

integrations:
needs: create-draft
secrets: inherit
uses: ./.github/workflows/_integration-tests.yaml
with:
image: europe-docker.pkg.dev/kyma-project/prod/serverless-operator:${{ github.ref_name }}
trigger_btp: true

publish-release:
name: Publish release
needs: [integrations, create-draft]
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Publish release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
latest_release="false"
if test $(git rev-parse latest) == $(git rev-parse )
./.github/scripts/publish-release.sh ${{ needs.create-draft.outputs.release_id }} ${latest_release}
82 changes: 12 additions & 70 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: create release
name: create release on tag

on:
workflow_dispatch:
Expand All @@ -12,10 +12,6 @@ on:
type: boolean
default: false

permissions: # used by build images steps
id-token: write # This is required for requesting the JWT token
contents: write # This is required for actions/checkout and builds

jobs:
verify-head-status:
name: Verify HEAD
Expand Down Expand Up @@ -77,73 +73,19 @@ jobs:
with:
fetch-depth: 0
ref: ${{ github.ref_name }} # Checkout to latest branch changes

- name: Tag latest
if: ${{ github.event.inputs.latest_release }}
# tag commit to inform another workload, responsible for creating right release
# that this release should be the latest one
run: |
git tag --force latest
git push --force origin latest
- name: Create tag
run: |
git tag ${{ github.event.inputs.name }}
git push origin ${{ github.event.inputs.name }}
builds:
needs: create-tag
uses: ./.github/workflows/_build.yaml
with:
tag: "${{ github.event.inputs.name }}"

create-draft:
name: Create draft release
needs: builds
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }} # checkout to latest branch changes ( by default this action checkouts to the SHA that triggers action )

- uses: ./.github/actions/setup-go

- name: Create draft release
id: create-draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RELEASE_ID=$(./.github/scripts/create-draft-release.sh ${{ github.event.inputs.name }})
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
- name: Create release assets
id: create-assets
env:
IMG: "europe-docker.pkg.dev/kyma-project/prod/serverless-operator:${{ github.event.inputs.name }}"
PULL_BASE_REF: ${{ github.event.inputs.name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ steps.create-draft.outputs.release_id }}
run: ./.github/scripts/release.sh

outputs:
release_id: ${{ steps.create-draft.outputs.release_id }}

integrations:
needs: create-draft
secrets: inherit
uses: ./.github/workflows/_integration-tests.yaml
with:
image: europe-docker.pkg.dev/kyma-project/prod/serverless-operator:${{ github.event.inputs.name }}
trigger_btp: true

publish-release:
name: Publish release
needs: [integrations, create-draft]
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.name }} # checkout to latest branch changes ( by default this action checkouts to the SHA that triggers action )

- name: Publish release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./.github/scripts/publish-release.sh ${{ needs.create-draft.outputs.release_id }} ${{ github.event.inputs.latest_release }}
# this workload ends on creating the right tag
# the next steps are located in the .github/workloads/create-release-tag.yaml file

0 comments on commit a4bdf17

Please sign in to comment.