Skip to content

Commit

Permalink
feat: Added support for flutter packages
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Feb 10, 2024
1 parent 5dca4bd commit ff6aeb2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Dart Conventional Release
description: Automating version bump for conventional dart releases
name: Dart/Flutter Conventional Release
description: Automating version bump for conventional dart/flutter releases
runs:
using: docker
image: Dockerfile
Expand All @@ -11,6 +11,10 @@ inputs:
description: 'Prefix that is used for the git tag'
default: 'v'
required: false
use-dart:
description: 'Prefix that is used for the git tag'
default: false
required: false
script-pre-run:
description: 'Path to a dart script that is executed before the version bump'
required: false
18 changes: 12 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ console.log(`Current workspace: ${workspace}`)
async function run() {
try {
await configureGit()
await installDartDependencies()
await installDependencies()
await executeScriptPreRun()

const pubspec = getPubspec()
Expand Down Expand Up @@ -59,7 +59,7 @@ async function run() {
updatePubspec(newVersion)

// Verification before publishing
await analyzeDartProject()
await analyzeProject()

// Setting up Git
await runInWorkspace('git', ['config', 'user.name', `"${process.env.GITHUB_USER || 'Dart Conventional Release'}"`])
Expand All @@ -69,7 +69,8 @@ async function run() {
await runInWorkspace('git', ['add', 'pubspec.yaml'])
await runInWorkspace('git', ['commit', '-m', `ci: ${commitMessage} ${newVersion}`])
// Tagging the commit
const tag = `v${newVersion}`
const tagPrefix = core.getInput('tag-prefix')
const tag = `${tagPrefix}${newVersion}`
await runInWorkspace('git', ['tag', tag])

// Pushing changes
Expand All @@ -91,8 +92,13 @@ async function configureGit() {
await runInWorkspace('git', ['config', '--global', '--add', 'safe.directory', workspace])
}

async function installDartDependencies() {
await runInWorkspace('dart', ['pub', 'get'])
async function installDependencies() {
const useDart = core.getInput('use-dart')
if (useDart) {
await runInWorkspace('dart', ['pub', 'get'])
} else {
await runInWorkspace('flutter', ['packages', 'get'])
}
}

// Run a script before the action (only if configured)
Expand Down Expand Up @@ -122,7 +128,7 @@ function incrementVersion(currentVersion, type) {
return semver.inc(currentVersion, type)
}

async function analyzeDartProject() {
async function analyzeProject() {
await runInWorkspace('dart', ['analyze'])
await runInWorkspace('dart', ['format', '--set-exit-if-changed', '.'])
await runInWorkspace('dart', ['pub', 'publish', '--dry-run'])
Expand Down

0 comments on commit ff6aeb2

Please sign in to comment.