Repository navigation
Expand file tree
/
Copy pathprepare-next-formulus-build-code.yml
More file actions
111 lines (98 loc) · 4.04 KB
/
Copy pathprepare-next-formulus-build-code.yml
File metadata and controls
111 lines (98 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Prepare Next Formulus Build Code
on:
workflow_dispatch:
inputs:
target_branch:
description: Branch that the release was prepared from and that should receive the next-code PR
required: true
default: dev
type: string
dry_run:
description: Validate and show the proposed update without creating a branch or pull request
required: true
default: true
type: boolean
workflow_call:
inputs:
target_branch:
description: Branch that the release was prepared from and that should receive the next-code PR
required: true
type: string
dry_run:
description: Validate and show the proposed update without creating a branch or pull request
required: false
default: false
type: boolean
concurrency:
group: prepare-next-formulus-build-code-${{ inputs.target_branch }}
cancel-in-progress: false
permissions:
contents: write
pull-requests: write
jobs:
prepare:
name: Prepare next native build-code block
runs-on: ubuntu-latest
steps:
- name: Verify target branch
env:
TARGET_BRANCH: ${{ inputs.target_branch }}
run: |
case "$TARGET_BRANCH" in
dev|main) ;;
*)
echo "::error::Target branch must be dev or main; received '$TARGET_BRANCH'."
echo "Create releases from one of those branches so the next-code PR has a safe target."
exit 1
;;
esac
- name: Checkout target branch
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ inputs.target_branch }}
- name: Set up Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: "24"
- name: Allocate the next four-code block
working-directory: formulus
run: node scripts/bumpNativeBuildCode.js
- name: Validate native versions
working-directory: formulus
run: node scripts/validateNativeVersions.js
- name: Check and display proposed change
run: |
git diff --check
git --no-pager diff -- formulus/android/app/build.gradle formulus/ios/Formulus.xcodeproj/project.pbxproj
- name: Check for an existing preparation pull request
if: inputs.dry_run == false
id: existing-pr
env:
GH_TOKEN: ${{ github.token }}
TARGET_BRANCH: ${{ inputs.target_branch }}
run: |
pr_url="$(gh pr list --base "$TARGET_BRANCH" --head "automation/prepare-next-formulus-build-code" --state open --json url --jq '.[0].url')"
echo "url=$pr_url" >> "$GITHUB_OUTPUT"
- name: Create preparation pull request
if: inputs.dry_run == false && steps.existing-pr.outputs.url == ''
env:
GH_TOKEN: ${{ github.token }}
TARGET_BRANCH: ${{ inputs.target_branch }}
run: |
set -eu
branch="automation/prepare-next-formulus-build-code"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git switch -c "$branch"
git add formulus/android/app/build.gradle formulus/ios/Formulus.xcodeproj/project.pbxproj
git commit -m "chore(release): reserve next Formulus build code"
git push --force origin "$branch"
gh pr create \
--base "$TARGET_BRANCH" \
--head "$branch" \
--title "chore(release): reserve next Formulus build code" \
--body "Automated preparation of the next four-code Android/iOS build-number block. Generated by [run ${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
- name: Report existing preparation pull request
if: inputs.dry_run == false && steps.existing-pr.outputs.url != ''
run: |
echo "A next-code preparation pull request is already open: ${{ steps.existing-pr.outputs.url }}"