Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DX-3037] ci: update release.yml #103

Merged
merged 2 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/action-gh-release@v0.2.0-a03
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
Loading