feat: Add support for managing pubspec_overrides.yaml #15
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Trigger Create Tag and Publish Workflow on PR Merge | |
on: | |
pull_request: | |
types: | |
- closed | |
jobs: | |
check-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Get version | |
id: yq | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -r '.version' 'pubspec.yaml' | |
- name: Print version | |
run: echo ${{ steps.yq.outputs.result }} | |
- name: Get Latest Tag | |
id: get_tag | |
run: | | |
REPO_NAME=${{ github.repository }} | |
LATEST_TAG=$(curl -s "https://api.github.com/repos/$REPO_NAME/releases" | jq -r '.[0].tag_name') | |
echo "latest=${LATEST_TAG}">> $GITHUB_OUTPUT | |
- name: Print version | |
run: echo "provided_version=${{ steps.yq.outputs.result }} and latest_tag=${{ steps.get_tag.outputs.latest }}" | |
- name: Check Version | |
id: check_version | |
run: | | |
latest_tag=${{ steps.get_tag.outputs.latest }} | |
provided_tag=${{ steps.yq.outputs.result }} | |
# Extract numerical version parts from the tags | |
latest_version=$(echo "$latest_tag" | sed 's/v\?\([0-9.]*\)[-a-zA-Z]*$/\1/') | |
provided_version=$(echo "$provided_tag" | sed 's/v\?\([0-9.]*\)[-a-zA-Z]*$/\1/') | |
echo "latest_version=${latest_version} and provided_version=${provided_version}" | |
echo "$provided_version" == "$latest_version" | |
if [[ "$provided_version" == "$latest_version" ]]; then | |
echo "Provided version is equal to latest version" | |
echo "trigger_next_action=false">> $GITHUB_OUTPUT | |
exit 1 | |
elif [[ "$provided_version" < "$latest_version" ]]; then | |
echo "Provided version is less than latest version" | |
echo "trigger_next_action=false">> $GITHUB_OUTPUT | |
exit 1 | |
else | |
echo "trigger_next_action=true">> $GITHUB_OUTPUT | |
fi | |
- name: Trigger Next Action | |
run: | | |
echo "Trigger Next Action ${{ steps.check_version.outputs.trigger_next_action }}" | |
echo "set-env:TRIGGER_NEXT_ACTION=${{ steps.check_version.outputs.trigger_next_action}}" >> $GITHUB_ENV | |
env: | |
TRIGGER_NEXT_ACTION: ${{ steps.check_version.outputs.trigger_next_action }} | |
trigger-create-tag-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if PR is merged into main | |
id: check_merged | |
run: | | |
sleep 120 | |
if [ "${{ github.event.pull_request.merged }}" = "true" ] && [ "${{ github.event.pull_request.base.ref }}" = "main" ]; then | |
echo "true" | |
else | |
echo "false" | |
fi | |
- name: Set trigger_create_tag_and_publish output | |
id: set_output | |
run: echo "set-env:TRIGGER_CREATE_TAG_AND_PUBLISH=${{ steps.check_merged.outputs.result}}" >> $GITHUB_ENV | |
env: | |
TRIGGER_CREATE_TAG_AND_PUBLISH: ${{ steps.check_merged.outputs.result}} | |
- name: Trigger dependent workflow | |
run: | | |
if [ "$TRIGGER_CREATE_TAG_AND_PUBLISH" = "true" && "$TRIGGER_NEXT_ACTION" = "true" ]; then | |
curl -X POST \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/${{ github.repository }}/actions/workflows/create_tag.yml/dispatches \ | |
-d '{"ref": "main"}' | |
fi | |