-
Notifications
You must be signed in to change notification settings - Fork 3
134 lines (117 loc) · 5.21 KB
/
Copy pathrelease.yml
File metadata and controls
134 lines (117 loc) · 5.21 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Release (CI-published p2 site)
# CI-published release flow that replaces the legacy in-repo, cumulative,
# hand-assembled P2 update site (see docs/RELEASING.md).
#
# What it does, on manual dispatch:
# 1. set the release version, build + test (Tycho), producing a complete
# per-version p2 repo at .../updatesite/target/repository
# (works because category.xml was added; no GUI / p2 publisher needed)
# 2. tag vX.Y.Z and create a GitHub Release with the p2 repo zipped as an asset
# 3. publish that repo to the gh-pages branch under /releases/X.Y.Z and
# regenerate the p2 *composite* indexes so the single Pages URL exposes
# every released version
# 4. bump master to the next development version
#
# No binaries are ever committed to master. The gh-pages branch holds the
# published site (an orphan branch independent of source history).
on:
workflow_dispatch:
inputs:
release_version:
description: "Release version (X.Y.Z)"
required: true
next_version:
description: "Next dev version (X.Y.Z, -SNAPSHOT added). Blank = bump minor."
required: false
permissions:
contents: write
concurrency:
group: release
cancel-in-progress: false
env:
UPDATESITE: edu.cuny.citytech.refactoring.common.updatesite
PAGES_URL: https://ponder-lab.github.io/Common-Eclipse-Refactoring-Framework
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
submodules: recursive
- uses: actions/setup-java@v4
with:
java-version: "21"
distribution: temurin
cache: maven
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Compute versions
id: v
run: |
REL="${{ github.event.inputs.release_version }}"
NEXT="${{ github.event.inputs.next_version }}"
[[ "$REL" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "bad release version"; exit 1; }
if [[ -z "$NEXT" ]]; then IFS=. read -r MA MI PA <<<"$REL"; NEXT="${MA}.$((MI+1)).0"; fi
echo "rel=$REL" >> "$GITHUB_OUTPUT"
echo "next=${NEXT}-SNAPSHOT" >> "$GITHUB_OUTPUT"
- name: Set release version
run: ./mvnw -B -q org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=${{ steps.v.outputs.rel }}
- name: Build, test, verify formatting
run: |
./mvnw -B spotless:check
./mvnw -B -U -DtrimStackTrace=true clean install
- name: Sanity-check the built p2 repo is non-empty
run: |
test -f "$UPDATESITE/target/repository/content.jar"
test -n "$(find "$UPDATESITE/target/repository/features" -name '*.jar')"
- name: Zip the p2 repo for the release asset
run: |
# write OUTSIDE the working tree so the release commit's `git add -A` can't capture it
(cd "$UPDATESITE/target/repository" && zip -qr "$RUNNER_TEMP/p2-repo-${{ steps.v.outputs.rel }}.zip" .)
- name: Commit release version, tag, push, and create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
REL="${{ steps.v.outputs.rel }}"
git add -A
git commit -q -m "Release v${REL}."
git tag -a "v${REL}" -m "Release v${REL}."
git push origin master
git push origin "v${REL}"
gh release create "v${REL}" \
--title "v${REL}" --generate-notes \
"$RUNNER_TEMP/p2-repo-${REL}.zip#p2 update site (zip)"
- name: Publish to gh-pages as a composite repository
run: |
REL="${{ steps.v.outputs.rel }}"
PAGES="$RUNNER_TEMP/pages" # OUTSIDE the working tree
git fetch origin gh-pages || true
rm -rf "$PAGES"
git worktree add -B gh-pages "$PAGES" "origin/gh-pages" 2>/dev/null \
|| git worktree add --orphan -B gh-pages "$PAGES"
rm -rf "$PAGES/releases/$REL"
mkdir -p "$PAGES/releases/$REL"
cp -r "$UPDATESITE/target/repository/." "$PAGES/releases/$REL/"
bash "$GITHUB_WORKSPACE/tools/p2-composite.sh" "$PAGES/releases" "Common Refactoring Framework" "$(date +%s000)"
# root index.html -> composite under /releases
printf '<meta http-equiv="refresh" content="0; url=releases/">\n' > "$PAGES/index.html"
( cd "$PAGES"
git add -A
git commit -q -m "Publish v$REL to composite p2 site" || echo "nothing to commit"
git push origin gh-pages )
git worktree remove --force "$PAGES"
- name: Prepare next development version
run: |
./mvnw -B -q org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=${{ steps.v.outputs.next }}
git add -A
git commit -q -m "Prepare next development version."
git push origin master
- name: Summary
run: |
echo "Released v${{ steps.v.outputs.rel }}" >> "$GITHUB_STEP_SUMMARY"
echo "Update site: ${PAGES_URL}/releases/" >> "$GITHUB_STEP_SUMMARY"
echo "master now on ${{ steps.v.outputs.next }}" >> "$GITHUB_STEP_SUMMARY"