Skip to content

Commit

Permalink
Improve release process automation steps.
Browse files Browse the repository at this point in the history
  • Loading branch information
christiandeange committed Nov 10, 2024
1 parent f5d0c13 commit c33c70e
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
jobs:
publish-release:
runs-on: macos-latest
if: github.repository == 'christiandeange/ozone'
if: github.repository == 'christiandeange/ozone' && github.ref == 'refs/heads/main'
timeout-minutes: 60

steps:
Expand Down
25 changes: 19 additions & 6 deletions .github/workflows/update_lexicons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,23 @@ jobs:
current_version: ${{ steps.get-latest-tag.outputs.tag }}
level: patch

- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
- name: Prepare Release Files
if: steps.changed-files.outputs.files_changed == 'true'
with:
commit_message: Update lexicons from atproto
tagging_message: ${{ steps.bump-semver.outputs.new_version }}
file_pattern: '*.api lexicons/schemas/**'
run: ./scripts/bump_version.sh ${{ steps.bump-semver.outputs.new_version }}

- name: Dry Run - Get Changed Files
uses: tj-actions/verify-changed-files@v20
id: all-changed-files

- name: Dry Run - List Changed Files
env:
ALL_CHANGED_FILES: ${{ steps.all-changed-files.outputs.changed_files }}
run: |
echo "Changed files: $ALL_CHANGED_FILES"
# - name: Commit Changes
# uses: stefanzweifel/git-auto-commit-action@v4
# if: steps.changed-files.outputs.files_changed == 'true'
# with:
# commit_message: [${{ steps.bump-semver.outputs.new_version }}] Update lexicons from atproto
# tagging_message: ${{ steps.bump-semver.outputs.new_version }}
45 changes: 0 additions & 45 deletions release.sh

This file was deleted.

30 changes: 30 additions & 0 deletions scripts/bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

set -euo pipefail

# Strip leading 'v' if present
NEXT_RELEASE="${1-}"
NEXT_RELEASE="${NEXT_RELEASE#v}"

if [[ -z "${NEXT_RELEASE}" ]]; then
echo "Usage: $0 <new-version>" >&2
exit 1
elif ! [[ "${NEXT_RELEASE}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
echo "Error: '${NEXT_RELEASE}' is not a valid semantic version." >&2
echo "Usage: $0 <new-version>" >&2
exit 1
fi

LAST_RELEASE="$(awk -F\" '/sh.christian.ozone:bluesky/ { print $4 }' < gradle/libs.versions.toml)"

properties_files="$(find . -name gradle.properties)"
for file in $properties_files; do
sed -i '' "s/POM_VERSION=.*/POM_VERSION=$NEXT_RELEASE/g" "$file"
done

sed -i '' "s/$LAST_RELEASE/$NEXT_RELEASE/g" gradle/libs.versions.toml
sed -i '' "s/$LAST_RELEASE/$NEXT_RELEASE/g" README.md

git add README.md
git add $properties_files
git add gradle/libs.versions.toml
19 changes: 19 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -euo pipefail

git checkout main

if [[ -n "$(git status --porcelain)" ]]; then
echo "Error: Uncommitted changes present. Please re-run with no local changes." >&2
exit 1
fi

# Strip leading 'v' if present
NEXT_RELEASE="${1-}"
NEXT_RELEASE="${NEXT_RELEASE#v}"

./scripts/bump_version.sh "${NEXT_RELEASE}"

git commit -m "Releasing v${NEXT_RELEASE}"
git tag "v$NEXT_RELEASE" --force

0 comments on commit c33c70e

Please sign in to comment.