Skip to content

Commit 243f566

Browse files
1.7.0 finish release (#3071)
* Rename workflow / replace trigger on push with dispatch * Add a temporary script with static version references to get 1.7.0 release announced
1 parent f5b0c13 commit 243f566

File tree

2 files changed

+113
-66
lines changed

2 files changed

+113
-66
lines changed

.announce170

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/bin/bash -e
2+
3+
if [ "$1" = "-y" ]; then
4+
AUTOACCEPT=true
5+
else
6+
AUTOACCEPT=false
7+
fi
8+
9+
VERSION="1.7.0"
10+
PREVIOUS_VERSION="1.6.0"
11+
12+
if [ -z "$PREVIOUS_VERSION" ]; then
13+
echo "Cannot find PREVIOUS_VERSION."
14+
exit 1
15+
fi
16+
17+
if [ "$VERSION" == "$PREVIOUS_VERSION" ]; then
18+
echo "VERSION $VERSION equal to PREVIOUS_VERSION $PREVIOUS_VERSION"
19+
exit 1
20+
fi
21+
22+
echo "Announcing $PREVIOUS_VERSION -> $VERSION"
23+
24+
DOCUMENTATION_DIR="documentation"
25+
RELEASE_DOCS_DIR="${DOCUMENTATION_DIR}/release-latest"
26+
SNAPSHOT_DOCS_DIR="${DOCUMENTATION_DIR}/snapshot"
27+
28+
if [ "$(git status --porcelain=v1 $DOCUMENTATION)" != "" ]; then
29+
echo "ERROR: To proceed, the current branch must not contain uncommitted changes in directory '${DOCUMENTATION_DIR}'"
30+
# ask for user confirmation
31+
if [[ "$AUTOACCEPT" = false ]]; then
32+
read -p "revert changes? (y/n)? " -n 1 -r
33+
echo
34+
if [[ $REPLY =~ ^[Yy]$ ]]; then
35+
git checkout ${DOCUMENTATION_DIR}
36+
else
37+
exit 1
38+
fi
39+
else
40+
echo "Reverting changes in directory '${DOCUMENTATION_DIR}'"
41+
git checkout ${DOCUMENTATION_DIR}
42+
fi
43+
fi
44+
45+
#escape_for_sed() { echo "$1" | sed -e 's/[]\/$*.^|[]/\\&/g'; }
46+
47+
# Make a separate branch because master branch is protected
48+
49+
BRANCH="$VERSION-update-refs"
50+
if [ "$(git show-ref refs/heads/$BRANCH)" != "" ]; then
51+
echo "ERROR: Branch $BRANCH already exists."
52+
if [[ "$AUTOACCEPT" = false ]]; then
53+
read -p "Delete local branch? (y/n)? " -n 1 -r
54+
echo
55+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
56+
exit 1
57+
else
58+
git branch -D $BRANCH
59+
fi
60+
else
61+
echo "Deleting local branch $BRANCH"
62+
git branch -D $BRANCH
63+
fi
64+
# Checkout local master branch so that changes to this script can be tested without pushing the script to the remote branch
65+
git checkout --track master -b $BRANCH
66+
else
67+
git checkout --track origin/master -b $BRANCH
68+
fi
69+
70+
# update version number in snapshot docs
71+
72+
echo "Updating version numbers in (snapshot) installation documentation"
73+
# On local machine (OSX) Use "sed -i '' ..." instead of "sed -i -e ..." as the latter creates a new file.
74+
# On Github Action workflow the "sed -i -e ..." is required as otherwise it results in failure
75+
# "can't read s/0.49.0/0.49.1/g: No such file or directory"
76+
sed -i -e "s/$PREVIOUS_VERSION/$VERSION/g" ${SNAPSHOT_DOCS_DIR}/docs/install/cli.md
77+
sed -i -e "s/$PREVIOUS_VERSION/$VERSION/g" ${SNAPSHOT_DOCS_DIR}/docs/install/integrations.md
78+
git --no-pager diff ${DOCUMENTATION_DIR}
79+
80+
# ask for user confirmation before committing
81+
if [[ "$AUTOACCEPT" = false ]]; then
82+
read -p "Accept changes (y/n)? " -n 1 -r
83+
echo
84+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
85+
exit 1
86+
fi
87+
fi
88+
89+
# Replace release documentation with current snapshot documentation.
90+
91+
echo "Replace release documentation with current snapshot documentation"
92+
# Support removal of files which still exists in release docs but which are no longer present in snapshot docs
93+
rm -rf ${RELEASE_DOCS_DIR}/docs/
94+
cp -r ${SNAPSHOT_DOCS_DIR}/docs/ ${RELEASE_DOCS_DIR}/docs/
95+
# Note that directory "${SNAPSHOT_DOCS_DIR}/overrides/" should not replace "${RELEASE_DOCS_DIR}/overrides/"
96+
cp -r ${SNAPSHOT_DOCS_DIR}/mkdocs.yml ${RELEASE_DOCS_DIR}
97+
# Add files which previously did not yet exists in the release docs but were present in the snapshot docs
98+
git add --all
99+
# Display sorted list of files changed but do not show contents as that could be a lot
100+
git status --porcelain=v1 documentation | sort
101+
102+
# Commit and push changes
103+
if [[ "$AUTOACCEPT" = false ]]; then
104+
read -p "Commit and push changes (y/n)? " -n 1 -r
105+
echo
106+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
107+
exit 1
108+
fi
109+
fi
110+
git commit -m "Updated refs to latest ($VERSION) release"
111+
git push origin $BRANCH

.github/workflows/publish-release-build-announce.yml

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -14,72 +14,8 @@ jobs:
1414

1515
- uses: ./.github/actions/setup-gradle-build
1616

17-
# - name: Build executable and publish to Maven
18-
# run: ./gradlew clean shadowJarExecutable publishMavenPublicationToMavenCentralRepository --no-daemon --no-parallel --no-configuration-cache
19-
# env:
20-
# CENTRAL_PORTAL_USERNAME: ${{ secrets.CENTRAL_PORTAL_USERNAME }}
21-
# CENTRAL_PORTAL_TOKEN: ${{ secrets.CENTRAL_PORTAL_TOKEN }}
22-
# ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}
23-
# ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEYID }}
24-
# ORG_GRADLE_PROJECT_signingKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}
25-
26-
- name: Validate changelog.md
27-
id: validate_changelog
28-
if: ${{ success() }}
29-
run: |
30-
FIRST_HEADING2=$(grep "^## " CHANGELOG.md | head -n 1)
31-
echo "First heading2 found: $FIRST_HEADING2"
32-
if [[ ! "$FIRST_HEADING2" =~ ^##[[:space:]]\[[0-9]+\.[0-9]+\.[0-9]+\][[:space:]]-[[:space:]][0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
33-
echo "First heading at level 2 should match '## [X.Y.Z] - [YYYY-MM-DD]'"
34-
exit 1
35-
fi
36-
37-
- name: Extract release notes
38-
id: release_notes
39-
if: ${{ success() }}
40-
uses: ffurrer2/extract-release-notes@v2
41-
42-
- name: Get version
43-
id: get_version
44-
if: ${{ success() }}
45-
run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
46-
47-
# - name: Create zip for dependency manager(s)
48-
# if: ${{ success() }}
49-
# run: |
50-
# cd ktlint-cli/build/run
51-
# mkdir -p ktlint-${{ env.version }}/bin
52-
# cp ktlint ktlint-${{ env.version }}/bin
53-
# zip -rm ktlint-${{ env.version }}.zip ktlint-${{ env.version }}
54-
55-
# - name: Create release
56-
# id: github_release
57-
# if: ${{ success() }}
58-
# uses: softprops/action-gh-release@v2
59-
# with:
60-
# draft: false
61-
# prerelease: false
62-
# body: ${{ steps.release_notes.outputs.release_notes }}
63-
# files: |
64-
# ktlint-cli/build/run/*
65-
# env:
66-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67-
68-
# - name: Bump Homebrew Formula
69-
# if: ${{ success() }}
70-
# uses: mislav/bump-homebrew-formula-action@v2
71-
# env:
72-
# COMMITTER_TOKEN: ${{ secrets.HOMEBREW_TOKEN }}
73-
# with:
74-
# formula-name: ktlint
75-
# formula-path: Formula/k/ktlint.rb
76-
# download-url: https://github.com/pinterest/ktlint/releases/download/${{ env.version }}/ktlint-${{ env.version }}.zip
77-
78-
- name: Update Release documentation
79-
if: ${{ success() }}
17+
- name: Announce 1.7.0 release
8018
run: |
8119
git config user.email "[email protected]"
8220
git config user.name "Ktlint Release Workflow" |
83-
./.announce -y
84-
env:
85-
VERSION: ${{ env.version }}
21+
./.announce170 -y

0 commit comments

Comments
 (0)