forked from openai/codex
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (99 loc) · 3.62 KB
/
Copy pathdcode-version-release.yml
File metadata and controls
103 lines (99 loc) · 3.62 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
name: dcode-version-release
on:
workflow_dispatch:
inputs:
bump:
description: Semantic version component to increment
required: true
type: choice
default: patch
options:
- patch
- minor
- major
permissions:
actions: write
contents: write
concurrency:
group: dcode-version-release
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Validate release source
shell: bash
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
SELECTED_REF: ${{ github.ref }}
run: |
set -euo pipefail
[[ "$SELECTED_REF" == "refs/heads/$DEFAULT_BRANCH" ]] || {
echo "Run this workflow from the default branch ($DEFAULT_BRANCH)." >&2
exit 1
}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 0
- uses: dtolnay/rust-toolchain@e081816240890017053eacbb1bdf337761dc5582 # 1.95.0
- name: Bump DCode release version
id: version
shell: bash
env:
BUMP: ${{ inputs.bump }}
run: |
set -euo pipefail
version="$(python3 scripts/bump_dcode_version.py --bump "$BUMP")"
changed="$(git diff --name-only)"
unexpected="$(printf '%s\n' "$changed" | grep -Ev '^(codex-rs/dcode-product/src/lib.rs|codex-rs/tui/src/.*/snapshots/.*\.snap)$' || true)"
[[ -z "$unexpected" ]] || {
echo "Unexpected version-bump changes:" >&2
printf '%s\n' "$unexpected" >&2
exit 1
}
grep -Fxq 'codex-rs/dcode-product/src/lib.rs' <<<"$changed"
git diff --check
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=dcode-v$version" >> "$GITHUB_OUTPUT"
- name: Commit version and create tag
shell: bash
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
TAG: ${{ steps.version.outputs.tag }}
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
git fetch origin "$DEFAULT_BRANCH" --tags
[[ "$(git rev-parse HEAD)" == "$(git rev-parse "origin/$DEFAULT_BRANCH")" ]] || {
echo "Default branch moved while preparing the release; rerun the workflow." >&2
exit 1
}
if git rev-parse --verify --quiet "refs/tags/$TAG"; then
echo "Tag $TAG already exists." >&2
exit 1
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -u codex-rs/dcode-product/src/lib.rs codex-rs/tui/src
git commit -m "Release DCode $VERSION"
git tag -a "$TAG" -m "DCode $VERSION"
git push --atomic origin "HEAD:refs/heads/$DEFAULT_BRANCH" "refs/tags/$TAG"
- name: Start release build
shell: bash
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
run: gh workflow run dcode-release.yml --repo "$GITHUB_REPOSITORY" --ref "$TAG"
- name: Add workflow summary
shell: bash
env:
TAG: ${{ steps.version.outputs.tag }}
VERSION: ${{ steps.version.outputs.version }}
run: |
{
echo "## DCode $VERSION"
echo
echo "Pushed \`$TAG\` and dispatched the multi-platform release build."
} >> "$GITHUB_STEP_SUMMARY"