Repository navigation
67 lines (62 loc) · 2.58 KB
/
Copy pathrelease-beta.yml
File metadata and controls
67 lines (62 loc) · 2.58 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
name: "Release beta"
run-name: "Release beta from ${{ github.ref_name }} at ${{ github.sha }}"
on:
workflow_dispatch:
inputs:
beta-number:
description: "Beta number, such as 1. Leave blank to choose the next number."
required: false
type: string
permissions:
contents: read
concurrency:
group: create-beta-tag
cancel-in-progress: false
queue: max
jobs:
create-tag:
name: Create beta tag
runs-on: ubuntu-latest
permissions:
contents: write # create an annotated beta tag
actions: write # dispatch the build at the created tag
steps:
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
persist-credentials: false
fetch-depth: 0
- name: Create tag and start beta build
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.repository }}
SOURCE_COMMIT: ${{ github.sha }}
SOURCE_BRANCH: ${{ github.ref_name }}
SOURCE_REF: ${{ github.ref }}
BETA_NUMBER: ${{ inputs.beta-number }}
run: |
if [[ "$SOURCE_REF" != refs/heads/release/cycle-* ]]; then
echo "Select a release-cycle branch named release/cycle-*"
exit 1
fi
commit=$(make -s beta-release/validate-source)
version=$(git show "$commit:build-logic/plugins/src/main/kotlin/AndroidCoordinates.kt" | sed -nE 's/^[[:space:]]*const val versionName = "([^"]+)".*/\1/p')
if [[ -z "$BETA_NUMBER" ]]; then
previous=$(git tag --list "v${version}-beta.*" | sed -nE 's/.*-beta\.([1-9][0-9]*)$/\1/p' | sort -n | tail -n1)
BETA_NUMBER=$(( ${previous:-0} + 1 ))
fi
if [[ ! "$BETA_NUMBER" =~ ^[1-9][0-9]*$ || -z "$version" ]]; then
echo "Expected an app version and a positive beta number without leading zeros"
exit 1
fi
tag="v${version}-beta.${BETA_NUMBER}"
if git show-ref --verify --quiet "refs/tags/$tag"; then
echo "$tag already exists. Choose another beta number."
exit 1
fi
tag_sha=$(gh api "repos/$REPOSITORY/git/tags" \
-f tag="$tag" -f message="Beta $tag" -f object="$commit" -f type=commit --jq '.sha')
gh api "repos/$REPOSITORY/git/refs" -f ref="refs/tags/$tag" -f sha="$tag_sha"
# Tags created with GITHUB_TOKEN do not trigger push workflows.
gh workflow run build-beta.yml --repo "$REPOSITORY" --ref "$tag"
echo "Started beta release $tag from $commit" >> "$GITHUB_STEP_SUMMARY"