Skip to content

feat: license header wip 2 #64

feat: license header wip 2

feat: license header wip 2 #64

Workflow file for this run

name: Test and Release
on:
push:
branches: ["*"]
pull_request:
branches: ["*"]
jobs:
commitlint:
name: Commitlint
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'chore(release):')"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
test:
name: Tests
runs-on: ubuntu-latest
needs: commitlint
outputs:
branch: ${{ steps.branchinfo.outputs.branch }}
steps:
- uses: actions/checkout@v4
- name: Store the branch name
id: branchinfo
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
- name: Check if we were able to save branch info
run: echo ${{ steps.branchinfo.outputs.branch }}
- name: Setup Dart SDK
uses: dart-lang/setup-dart@v1
- name: Get dependencies
run: dart pub get
- name: Check dart formatting
run: dart format --set-exit-if-changed .
- name: Statically analyze the Dart code for any errors.
run: dart analyze .
- name: Run Tests with coverage
run: dart run coverage:test_with_coverage
- name: Upload coverage
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: coverage/lcov.info
release:
name: Prepare Release
runs-on: ubuntu-latest
needs: test
if: github.event_name != 'pull_request' && needs.test.outputs.branch == 'main'
steps:
- name: Setup Dart SDK
uses: dart-lang/setup-dart@v1
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- name: Get dependencies
run: dart pub get
- name: Get current version
id: currentVersion
run: echo "value=$(dart run release_tools current_version)" >> $GITHUB_OUTPUT
- name: Get commitId of last tag of that version
id: lastCommitId
run: echo "value=$(dart run release_tools remote_tag_id ${{ steps.currentVersion.outputs.value }})" >> $GITHUB_OUTPUT
- name: Use commitId to check if we should release
id: shouldRelease
run: echo "value=$(dart run release_tools should_release --from ${{ steps.lastCommitId.outputs.value }})" >> $GITHUB_OUTPUT
- run: echo "Should we release? ${{ steps.shouldRelease.outputs.value }}"
- name: If we should release get the next version
if: steps.shouldRelease.outputs.value == 'yes'
id: nextVersion
run: echo "value=$(dart run release_tools next_version --ensureMajor --from ${{ steps.lastCommitId.outputs.value }})" >> $GITHUB_OUTPUT
- run: echo "RELEASING ${{ steps.nextVersion.outputs.value }}"
- name: Update versions
if: steps.shouldRelease.outputs.value == 'yes'
id: updateVersion
run: |
dart run release_tools update_version ${{ steps.nextVersion.outputs.value }}
dart run release_tools update_version --file="lib/release_tools_version.dart" ${{ steps.nextVersion.outputs.value }}
dart run release_tools update_version --file="README.md" --template="pub global activate release_tools [VERSION]" ${{ steps.nextVersion.outputs.value }}
- name: Write changelog
id: changelog
if: steps.shouldRelease.outputs.value == 'yes'
run: |
output=$(dart run release_tools changelog --from ${{ steps.lastCommitId.outputs.value }} ${{ steps.nextVersion.outputs.value }})
output="${output//'%'/'%25'}"
output="${output//$'\n'/'%0A'}"
output="${output//$'\r'/'%0D'}"
echo "summary=$output" >> $GITHUB_OUTPUT
- name: Commit Release
if: steps.shouldRelease.outputs.value == 'yes'
run: |
git diff
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "chore(release): release for ${{ steps.nextVersion.outputs.value }}"
git push
- name: Create Release
if: steps.shouldRelease.outputs.value == 'yes'
id: createRelease
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.PAT }}
tag: ${{ steps.nextVersion.outputs.value }}
name: Release ${{ steps.nextVersion.outputs.value }}
body: |
Changes in this Release
${{ steps.nextVersion.outputs.value }}