Skip to content

Commit

Permalink
ci: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
aeharding committed Nov 13, 2024
1 parent 9f8d46f commit 735c93c
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
RELEASE_BRANCH_PREFIX: release # test-release

jobs:
app_build_number:
app_build:
runs-on: ubuntu-latest
steps:
- id: calculate
Expand All @@ -28,11 +28,10 @@ jobs:
outputs:
app_build: ${{ steps.calculate.outputs.app_build }}

validate_version:
needs: app_build_number
app_version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_current_version.outputs.version }}
app_version: ${{ steps.app_version.outputs.app_version }}
steps:
- uses: actions/checkout@v4

Expand All @@ -41,23 +40,23 @@ jobs:
node-version: 22

- name: Get current version from package.json
id: get_current_version
id: app_version
run: |
CURRENT_APP_VERSION=$(node -p "require('./package.json').version")
echo "version=$CURRENT_APP_VERSION" >> $GITHUB_OUTPUT
echo "app_version=$CURRENT_APP_VERSION" >> $GITHUB_OUTPUT
- name: Verify provided version not already released
if: github.ref_name != 'main'
run: |
git fetch --tags
TAG_NAME="$TAG_PREFIX${{ steps.get_current_version.outputs.version }}"
TAG_NAME="$TAG_PREFIX${{ steps.app_version.outputs.app_version }}"
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Error: Tag $TAG_NAME already exists"
exit 1
fi
bump_src:
needs: [app_build_number, validate_version]
needs: [app_build, app_version]
runs-on: ubuntu-latest

steps:
Expand All @@ -71,8 +70,8 @@ jobs:
- name: Run trapeze (update iOS and Android version/code)
run: pnpm exec trapeze run trapeze.yaml -y
env:
APP_BUILD: ${{ needs.app_build_number.outputs.app_build }}
APP_VERSION: ${{ needs.validate_version.outputs.version }}
APP_BUILD: ${{ needs.app_build.outputs.app_build }}
APP_VERSION: ${{ needs.app_version.outputs.app_version }}

- name: Upload bumped version artifacts
uses: actions/upload-artifact@v4
Expand All @@ -94,7 +93,7 @@ jobs:
contents: write # needed for create_release, even though it won't be called

push_release:
needs: [bump_src, validate_version]
needs: [bump_src, app_build, app_version]
runs-on: ubuntu-latest
if: startsWith(github.ref_name, 'test-') != true && startsWith(github.ref, 'refs/tags/')

Expand Down Expand Up @@ -122,13 +121,13 @@ jobs:
# Github doesn't trigger subsequent workflows unless push with a PAT
run: |
git remote set-url origin "https://${PAT_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git checkout -b "$RELEASE_BRANCH_PREFIX/${{ needs.validate_version.outputs.version }}"
git checkout -b "$RELEASE_BRANCH_PREFIX/${{ needs.app_version.outputs.app_version }}"
git config --global user.email "[email protected]"
git config --global user.name "Voyager CI"
git add .
git commit -S -m "release: ${{ needs.validate_version.outputs.version }} (${{ needs.app_build_number.outputs.app_build }})"
TAG_NAME="${TAG_PREFIX}${{ needs.validate_version.outputs.version }}"
git commit -S -m "release: ${{ needs.app_version.outputs.app_version }} (${{ needs.app_build.outputs.app_build }})"
TAG_NAME="${TAG_PREFIX}${{ needs.app_version.outputs.app_version }}"
echo "Creating tag: $TAG_NAME"
git tag -s "$TAG_NAME"
git push origin "$RELEASE_BRANCH_PREFIX/${{ needs.validate_version.outputs.version }}"
git push origin "$RELEASE_BRANCH_PREFIX/${{ needs.app_version.outputs.app_version }}"
git push origin "$TAG_NAME"

0 comments on commit 735c93c

Please sign in to comment.