Skip to content

Commit

Permalink
split into two workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Manindra de Me committed Dec 3, 2024
1 parent 6ef095b commit 3a960a1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Publish to pub.dev

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'

jobs:
publish:
permissions:
id-token: write # Required for authentication using OIDC
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
31 changes: 14 additions & 17 deletions .github/workflows/update_metadata.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
name: Update Metadata and Publish
name: Update Metadata

on:
schedule:
# At 12:00 AM, on day 1 of each month
- cron: "0 0 1 * *"
workflow_dispatch:

jobs:
update-and-publish:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for git describe

- uses: dart-lang/setup-dart@v1

- name: Install dependencies
Expand All @@ -26,29 +30,22 @@ jobs:
dart pub get
dart resources/generate_files.dart && dart format lib/src && dart fix --apply
- name: Update Version
- name: Update Version and Create Tag
run: |
# Read the current version from pubspec.yaml
CURRENT_VERSION=$(grep 'version:' pubspec.yaml | sed 's/version: //')
# Increment the patch version
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
# Update pubspec.yaml with new version
sed -i "s/version: $CURRENT_VERSION/version: $NEW_VERSION/" pubspec.yaml
- name: Commit and Push Updated Files
run: |
# Commit and push changes
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git add .
git commit -m "Update Metadata and bump version" || echo "Nothing to commit!"
git commit -m "Update Metadata and bump version to $NEW_VERSION" || exit 0
git push
- name: Publish to pub.dev
env:
PUB_CREDENTIALS: ${{ secrets.PUB_CREDENTIALS }}
run: |
# Create credentials file
mkdir -p ~/.pub-cache
echo "$PUB_CREDENTIALS" > ~/.pub-cache/credentials.json
# Publish package
dart pub publish --force
# Create and push tag
git tag "v$NEW_VERSION"
git push origin "v$NEW_VERSION"

0 comments on commit 3a960a1

Please sign in to comment.