Skip to content

Apply suggestions from code review #5

Apply suggestions from code review

Apply suggestions from code review #5

---
name: Pre/Post Release
on:
workflow_call:
inputs:
ref:
description: 'Branch or tag ref to run the workflow on'
type: string
required: true
default: 'main'
version:
description: 'The version to release (e.g. 1.2.3). This workflow will automatically perform the required version bumps'
type: string
required: true
phase:
description: 'Pre or post release phase'
type: string # valid values are 'pre' or 'post'
required: true
pr_title:
description: 'pull-request title'
type: string
required: true
pr_body:
description: 'pull-request body'
type: string
required: true
env:
RELEASE_VERSION: ${{ inputs.version }}
BRANCH_NAME: ${{ inputs.phase }}-release-v${{ inputs.version }}
permissions:
contents: read
jobs:
validate-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Validate tag does not exist on current commit
uses: ./.github/workflows/validate-tag
with:
tag: v${{ env.RELEASE_VERSION }}
create-pr:
name: "Bump versions and create PR"
runs-on: ubuntu-latest
needs:
- validate-tag
steps:

Check failure on line 54 in .github/workflows/pre-post-release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/pre-post-release.yml

Invalid workflow file

You have an error in your yaml syntax on line 54
- name: Get token
id: get_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private-key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permission-contents: write
permission-pull-requests: write
repositories: |
ecs-logging-java
- uses: actions/checkout@v5
with:
ref: ${{ inputs.ref }}
token: ${{ steps.get_token.outputs.token }}
- uses: elastic/oblt-actions/git/setup@v1
with:
github-token: ${{ steps.get_token.outputs.token }}
- name: Create the release tag (post phase)
if: inputs.phase == 'post'
run: |
git tag "v${{ env.RELEASE_VERSION }}"
git push origin "v${{ env.RELEASE_VERSION }}"
- name: Create a ${{ inputs.phase }} release branch
run: git checkout -b ${{ env.BRANCH_NAME }}
- name: Set release version (pre release)
if: inputs.phase == 'pre'
uses: ./.github/workflows/maven-goal
with:
command: ./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -DnewVersion=${{ env.RELEASE_VERSION }}
- name: Set next snapshot version (post release)
if: inputs.phase == 'post'
uses: ./.github/workflows/maven-goal
with:
command: ./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -DnextSnapshot=true
- name: Push the ${{ inputs.phase }} release branch
run: |
git add --all
git commit -m "${PHASE} release: ecs-logging-java v${{ env.RELEASE_VERSION }}"
git push origin ${{ env.BRANCH_NAME }}
env:
PHASE: ${{ inputs.phase }}
- name: Create the ${{ inputs.phase }} release PR
run: gh pr create --title="${PR_TITLE}" --base main --head ${{ env.BRANCH_NAME }} -b "${PR_BODY}"
env:
GH_TOKEN: ${{ steps.get_token.outputs.token }}
PR_TITLE: ${{ inputs.pr_title }}
PR_BODY: ${{ inputs.pr_body }}