Skip to content

Commit

Permalink
[DX-3037] ci: update release.yml (#103)
Browse files Browse the repository at this point in the history
* ci: update release.yml

* ci: update update-version.xml, add tag workflow which creates a release
  • Loading branch information
nattb8 authored Jul 28, 2024
1 parent da49d22 commit 7201079
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 36 deletions.
22 changes: 22 additions & 0 deletions .github/scripts/check_team_membership.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -x

USER=$1

response=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/orgs/immutable/teams/sdk/memberships/${USER}")

echo "$response"

if echo "$response" | grep -q '"state":"active"'; then
IS_MEMBER=true
else
IS_MEMBER=false
fi
echo "$IS_MEMBER"

# Set the environment variable for the GitHub workflow
echo "IS_MEMBER=$IS_MEMBER" >> "$GITHUB_ENV"
34 changes: 28 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
---
name: 'Create Release'

on:
push:
tags:
- '*'
workflow_run:
workflows: ["Tag Release"]
types:
- completed

jobs:
release:
if: startsWith(github.ref, 'refs/tags/')
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Extract TS SDK version from index.html
id: extract_ts_sdk_version
run: |
version=$(grep -oP '"x-sdk-version":"ts-immutable-sdk-\K[0-9]+\.[0-9]+\.[0-9]+' ./Web/index.js | head -n 1)
if [[ -z "$version" ]]; then
echo "Error: Version not found in index.js" >&2
exit 1
fi
version=$(echo "$version" | tr -d '\r\n')
echo "VERSION=${version}" >> "$GITHUB_ENV"
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v3
Expand All @@ -33,6 +52,9 @@ jobs:
- name: Create Release
uses: mikepenz/[email protected]
with:
body: ${{steps.github_release.outputs.changelog}}
body: |
${{steps.github_release.outputs.changelog}}
Game bridge built from Immutable Typescript SDK version ${{ env.VERSION }}

36 changes: 36 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: "Tag Release"

on:
pull_request:
types: [closed]

jobs:
create-tag:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Extract version from ImmutableDataTypes.h
id: extract_version
run: |
version=$(grep -oP '#define ENGINE_SDK_VERSION TEXT\("\K[0-9]+\.[0-9]+\.[0-9]+' ImmutableDataTypes.h)
if [[ -z "$version" ]]; then
echo "Error: Version not found in ImmutableDataTypes.h" >&2
exit 1
fi
version=$(echo "$version" | tr -d '\r\n')
echo "VERSION=${version}" >> "$GITHUB_ENV"
- name: Create Tag
uses: negz/create-tag@v1
with:
version: "v${{ env.VERSION }}"
message: "Version ${{ env.VERSION }}"
token: ${{ secrets.GITHUB_TOKEN }}
75 changes: 45 additions & 30 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
---
name: "Update engine SDK version in Immutable Data Types"

on:
workflow_dispatch:
inputs:
version:
description: 'Version to update to (e.g. 1.20.0)'
required: true

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
name: "Update engine SDK version in ImmutableDataTypes.h"

# - name: Check team membership
# id: check_team
# run: |
# IS_MEMBER=$(./.github/scripts/check_team_membership.sh "${{ github.actor }}" "${{ secrets.GITHUB_TOKEN }}")
# if [[ "$IS_MEMBER" != "true" ]]; then
# echo "Not a member of the SDK team, skipping update"
# exit 1
# fi

- name: Replace engine sdk version string
id: replace_engine_sdk_version
run: |
FILE=./Source/Immutable/Public/Immutable/ImmutableDataTypes.h
VERSION=${{ github.event.inputs.version }}
sed -i -E "s/#define ENGINE_SDK_VERSION TEXT\(\"[0-9]+\.[0-9]+\.[0-9]+\"\)/#define ENGINE_SDK_VERSION TEXT(\"$VERSION\")/g" $FILE
on:
workflow_dispatch:
inputs:
version:
description: 'Version to update to (e.g. 1.20.0)'
required: true

jobs:
update:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.UNREAL_IMMUTABLE_SDK_GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Check team membership
id: check_team
run: |
./.github/scripts/check_team_membership.sh "${{ github.actor }}" "${{ secrets.UNREAL_IMMUTABLE_SDK_GITHUB_TOKEN }}"
# shellcheck disable=SC1090
source "$GITHUB_ENV"
echo "${{ github.actor }} is a member of the SDK team: $IS_MEMBER"
if [[ "$IS_MEMBER" != "true" ]]; then
echo "Not a member of the SDK team, skipping update"
exit 1
fi
- name: Replace engine sdk version string
id: replace_engine_sdk_version
run: |
FILE=./Source/Immutable/Public/Immutable/ImmutableDataTypes.h
VERSION=${{ github.event.inputs.version }}
sed -i -E "s/#define ENGINE_SDK_VERSION TEXT\(\"[0-9]+\.[0-9]+\.[0-9]+\"\)/#define ENGINE_SDK_VERSION TEXT(\"$VERSION\")/g" $FILE
- uses: gr2m/create-or-update-pull-request-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: "release: update version"
body: "Update version in ImmutableDataTypes.h"
branch: "release/update-version"
commit-message: "release: update version"
labels: release

0 comments on commit 7201079

Please sign in to comment.