Tag Arena Mobile Release #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tag Arena Mobile Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| arena_mobil_version: | |
| description: 'Arena Mobile version (e.g. 4.4.0)' | |
| required: true | |
| dui_version: | |
| description: 'DUI version used in this Arena Mobile release. Find it in the Arena Mobile .csproj PackageReference for DIPS.Mobile.UI (e.g. 54.4.7)' | |
| required: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| create-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Fetch all remote branches | |
| run: git fetch --all | |
| - name: Detect commit SHA from DUI version in CHANGELOG | |
| id: detect_sha | |
| run: | | |
| SHA=$(git log --all -S "## [${{ inputs.dui_version }}]" --format="%H" -- CHANGELOG.md | head -1) | |
| if [ -z "$SHA" ]; then | |
| echo "Error: Could not find a commit introducing '## [${{ inputs.dui_version }}]' in CHANGELOG.md" | |
| exit 1 | |
| fi | |
| echo "commit_sha=$SHA" >> $GITHUB_OUTPUT | |
| echo "Found commit SHA: $SHA" | |
| - name: Create Arena Mobile release | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const version = '${{ inputs.arena_mobil_version }}'; | |
| const commitSha = '${{ steps.detect_sha.outputs.commit_sha }}'; | |
| const tagName = `arena-mobil-${version}`; | |
| const releaseName = `Arena Mobil ${version}`; | |
| const body = `This version of DUI was used in Arena Mobil ${version} app. Available in App Store and Google Play.`; | |
| try { | |
| await github.rest.repos.createRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: tagName, | |
| target_commitish: commitSha, | |
| name: releaseName, | |
| body: body, | |
| draft: false, | |
| prerelease: false | |
| }); | |
| console.log(`Release ${tagName} created successfully at ${commitSha}`); | |
| } catch (e) { | |
| const isAlreadyExistsError = | |
| e.status === 422 && | |
| Array.isArray(e.response?.data?.errors) && | |
| e.response.data.errors.some(error => error?.code === 'already_exists'); | |
| if (isAlreadyExistsError) { | |
| console.log(`Release ${tagName} already exists, skipping.`); | |
| } else { | |
| throw e; | |
| } | |
| } |