mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-04-22 03:26:11 +02:00
70 lines
2.2 KiB
YAML
70 lines
2.2 KiB
YAML
name: Auto Release on Version Bump
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'pubspec.yaml'
|
|
|
|
jobs:
|
|
check-version:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version_changed: ${{ steps.check.outputs.changed }}
|
|
new_version: ${{ steps.check.outputs.version }}
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 2
|
|
|
|
- name: Check if version changed
|
|
id: check
|
|
run: |
|
|
# Get current version
|
|
CURRENT_VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //' | cut -d'+' -f1)
|
|
|
|
# Get previous version
|
|
git show HEAD~1:pubspec.yaml > /tmp/old_pubspec.yaml 2>/dev/null || echo "version: 0.0.0" > /tmp/old_pubspec.yaml
|
|
PREVIOUS_VERSION=$(grep '^version:' /tmp/old_pubspec.yaml | sed 's/version: //' | cut -d'+' -f1)
|
|
|
|
echo "Current version: $CURRENT_VERSION"
|
|
echo "Previous version: $PREVIOUS_VERSION"
|
|
|
|
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
|
|
echo "Version changed!"
|
|
echo "changed=true" >> $GITHUB_OUTPUT
|
|
echo "version=v$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "Version unchanged"
|
|
echo "changed=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
create-tag-and-trigger-release:
|
|
needs: check-version
|
|
if: needs.check-version.outputs.version_changed == 'true'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
actions: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Create and push tag
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git tag ${{ needs.check-version.outputs.new_version }}
|
|
git push origin ${{ needs.check-version.outputs.new_version }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Trigger Release workflow
|
|
run: |
|
|
gh workflow run release.yml -f version=${{ needs.check-version.outputs.new_version }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|