Skip to content

Commit

Permalink
chore: setup semantic release, #1
Browse files Browse the repository at this point in the history
  • Loading branch information
luifr10 committed Mar 5, 2024
1 parent 9054f0c commit 4878627
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish to pub.dev

on:
push:
tags:
# must align with the tag-pattern configured on pub.dev, often just replace
# {{version}} with [0-9]+.[0-9]+.[0-9]+*
# - 'v[0-9]+.[0-9]+.[0-9]+*' # tag-pattern on pub.dev: 'v{{version}}'
# If you prefer tags like '1.2.3', without the 'v' prefix, then use:
# - '[0-9]+.[0-9]+.[0-9]+*' # tag-pattern on pub.dev: '{{version}}'
- '**' # tag-pattern on pub.dev: '{{version}}'
# If your repository contains multiple packages consider a pattern like:
# - 'my_package_name-v[0-9]+.[0-9]+.[0-9]+*'

# Publish using the reusable workflow from dart-lang.
jobs:
publish:
environment: publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Publish
uses: k-paxian/dart-package-publisher@master
with:
credentialJson: ${{ secrets.CREDENTIAL_JSON }}
flutter: true
skipTests: true
dryRunOnly: false
35 changes: 13 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ on:
branches: [ "main" ]

env:
NODE_VERSION: 18.14.0
NODE_VERSION: 20.8.1
FLUTTER_VERSION: '3.16.9'

jobs:
analyse:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: $FLUTTER_VERSION
flutter-version: ${{env.FLUTTER_VERSION}}
channel: 'stable'
- run: flutter analyse
- run: flutter analyze

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: $FLUTTER_VERSION
flutter-version: ${{env.FLUTTER_VERSION}}
channel: 'stable'
- run: flutter test

release:
if: github.ref == 'refs/heads/main'
needs: [ analyse, test ]
if: github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):')
needs: [ analyze, test ]
runs-on: ubuntu-latest
environment: release
steps:
Expand All @@ -45,20 +45,11 @@ jobs:
with:
node-version: ${{env.NODE_VERSION}}
registry-url: 'https://registry.npmjs.org'
- name: Build new release
run: npx semantic-release
- name: Install NPM dependencies
shell: bash

publish:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [ release ]
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: $FLUTTER_VERSION
channel: 'stable'
- name: Publish on pub.dev
run: dart publish
run: npm ci
- name: Build new release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
shell: bash
run: npx semantic-release
6 changes: 5 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"branches": [
{ "name": "beta-mode" },
{ "name": "main", "channel": "beta", "prerelease": "beta" }
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
Expand Down Expand Up @@ -30,7 +34,7 @@
"pubspec.yaml",
"CHANGELOG.md"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
}]
]
}

0 comments on commit 4878627

Please sign in to comment.