Skip to content

Commit

Permalink
Update bump_internal_release.yml to use fastlane action
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Oct 2, 2024
1 parent e43d34c commit cec4294
Showing 1 changed file with 13 additions and 74 deletions.
87 changes: 13 additions & 74 deletions .github/workflows/bump_internal_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
timeout-minutes: 10

outputs:
skip-release: ${{ steps.check-for-changes.outputs.skip-release }}
asana-task-url: ${{ steps.set-parameters.outputs.asana-task-url }}
release-branch: ${{ steps.set-parameters.outputs.release-branch }}
skip-appstore: ${{ steps.set-parameters.outputs.skip-appstore }}
skip-release: ${{ steps.prepare-release-bump.outputs.skip_release }}
asana-task-url: ${{ steps.prepare-release-bump.outputs.release_task_url }}
release-branch: ${{ steps.prepare-release-bump.outputs.release_branch }}
skip-appstore: ${{ steps.prepare-release-bump.outputs.skip_appstore }}

steps:

Expand All @@ -53,80 +53,19 @@ jobs:
- name: Set up fastlane
run: bundle install

# When running on schedule there are no inputs, so the workflow has to find the Asana task
- name: Find Asana release task
id: find-asana-task
if: github.event.inputs.asana-task-url == null
- name: Prepare release bump
id: prepare-release-bump
env:
ASANA_ACCESS_TOKEN: ${{ secrets.ASANA_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
run: |
bundle exec fastlane run asana_find_release_task platform:macos
# When running on schedule, only proceed if there are changes to the release branch (i.e. HEAD is not tagged)
- name: Check if there are changes to the release branch
id: check-for-changes
env:
release_branch: ${{ steps.find-asana-task.outputs.release_branch || github.ref_name }}
run: |
if [[ "${{ github.event_name }}" != "schedule" ]]; then
echo "skip-release=false" >> $GITHUB_OUTPUT
else
latest_tag="$(git describe --tags --abbrev=0)"
latest_tag_sha="$(git rev-parse "$latest_tag"^{})"
release_branch_sha="$(git rev-parse "origin/${release_branch}")"
if [[ "${latest_tag_sha}" == "${release_branch_sha}" ]]; then
echo "::warning::Release branch's HEAD is already tagged. Skipping automatic release."
echo "skip-release=true" >> $GITHUB_OUTPUT
else
changed_files="$(git diff --name-only "$latest_tag".."origin/${release_branch}")"
if grep -q -v -e '.github' -e 'scripts' <<< "$changed_files"; then
echo "::warning::New code changes found in the release branch since the last release. Will bump internal release now."
echo "skip-release=false" >> $GITHUB_OUTPUT
else
echo "::warning::No changes to the release branch (or only changes to scripts and workflows). Skipping automatic release."
echo "skip-release=true" >> $GITHUB_OUTPUT
fi
fi
fi
- name: Extract Asana Task ID
id: task-id
if: github.event.inputs.asana-task-url
run: bundle exec fastlane run asana_extract_task_id task_url:"${{ github.event.inputs.asana-task-url }}"

- name: Set parameters
id: set-parameters
env:
ASANA_TASK_URL: ${{ steps.find-asana-task.outputs.release_task_url || github.event.inputs.asana-task-url }}
RELEASE_BRANCH: ${{ steps.find-asana-task.outputs.release_branch || github.ref_name }}
TASK_ID: ${{ steps.find-asana-task.outputs.release_task_id || steps.task-id.outputs.asana_task_id }}
SKIP_APPSTORE: ${{ github.event.inputs.skip-appstore || false }} # make sure this is set to false on scheduled runs
run: |
if [[ "${RELEASE_BRANCH}" == "main" ]]; then
echo "::error::Workflow run from main branch and release branch wasn't found. Please re-run the workflow and specify a release branch."
exit 1
fi
echo "release-branch=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT
echo "task-id=${TASK_ID}" >> $GITHUB_OUTPUT
echo "asana-task-url=${ASANA_TASK_URL}" >> $GITHUB_OUTPUT
echo "skip-appstore=${SKIP_APPSTORE}" >> $GITHUB_OUTPUT
- name: Validate release notes
env:
TASK_ID: ${{ steps.set-parameters.outputs.task-id }}
ASANA_ACCESS_TOKEN: ${{ secrets.ASANA_ACCESS_TOKEN }}
run: |
curl -fLSs "https://app.asana.com/api/1.0/tasks/${TASK_ID}?opt_fields=notes" \
-H "Authorization: Bearer ${ASANA_ACCESS_TOKEN}" \
| jq -r .data.notes \
| ./scripts/extract_release_notes.sh -r > raw_release_notes.txt
raw_release_notes="$(<raw_release_notes.txt)"
if [[ ${#raw_release_notes} == 0 || "$raw_release_notes" == *"<-- Add release notes here -->"* ]]; then
echo "::error::Release notes are empty or contain a placeholder. Please add release notes to the Asana task and restart the workflow."
exit 1
fi
bundle exec fastlane run bump_internal_release \
platform:macos \
base_branch:"${{ inputs.base-branch }}" \
github_handle:"${{ github.actor }}" \
is_scheduled_release:"${{ github.event_name == 'schedule' }}" \
skip_appstore:"${{ inputs.skip-appstore }}" \
release_task_url:"${{ inputs.asana-task-url }}"
run_tests:

Expand Down

0 comments on commit cec4294

Please sign in to comment.