diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c47701..c88fbbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,8 +20,20 @@ jobs: # This job will run on ubuntu virtual machine runs-on: ubuntu-latest needs: commitlint + outputs: + branch: ${{ steps.branchinfo.outputs.branch }} + steps: + - uses: nelonoel/branch-name@v1.0.1 + # Use branch name for whatever purpose + - name: Store the branch name + id: branchinfo + run: echo "::set-output name=branch::${BRANCH_NAME}" + + - name: Check if we were able to save branch info + run: echo ${{ steps.branchinfo.outputs.branch }} + - uses: cedx/setup-dart@v2 with: release-channel: stable @@ -48,4 +60,101 @@ jobs: uses: coverallsapp/github-action@v1.1.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: lcov.info \ No newline at end of file + path-to-lcov: lcov.info + + release: + name: Release + runs-on: ubuntu-latest + needs: test + if: ${{ needs.test.outputs.branch == 'main' }} + + steps: + - run: echo ${{ needs.test.outputs.branch }} + + - uses: cedx/setup-dart@v2 + with: + release-channel: stable + + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Get dependencies + run: pub get + + - name: Get current version + id: currentVersion + run: echo "::set-output name=value::$(pub run release_tools current_version)" + + - run: echo ${{ steps.currentVersion.outputs.value }} + + - name: Get commitId of last tag of that version + id: lastCommitId + run: echo "::set-output name=value::$(pub run release_tools remote_tag_id ${{ steps.currentVersion.outputs.value }})" + + - run: echo ${{ steps.lastCommitId.outputs.value }} + + - name: Use commitId to check if we should release + id: shouldRelease + run: echo "::set-output name=value::$(pub run release_tools should_release --from ${{ steps.lastCommitId.outputs.value }})" + + - run: echo ${{ steps.shouldRelease.outputs.value }} + + - name: If we should release get the next version + if: steps.shouldRelease.outputs.value == 'yes' + id: nextVersion + run: echo "::set-output name=value::$(pub run release_tools next_version --from ${{ steps.lastCommitId.outputs.value }})" + + - run: echo ${{ steps.nextVersion.outputs.value }} + + - name: Update version + if: steps.shouldRelease.outputs.value == 'yes' + id: updateVersion + run: pub run release_tools update_version ${{ steps.nextVersion.outputs.value }} + + - name: Write changelog + id: changelog + if: steps.shouldRelease.outputs.value == 'yes' + run: | + output=$(pub run release_tools changelog --from ${{ steps.lastCommitId.outputs.value }} ${{ steps.nextVersion.outputs.value }}) + echo "::set-output name=summary::$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: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.nextVersion.outputs.value }} + release_name: Release ${{ steps.nextVersion.outputs.value }} + body: | + Changes in this Release + + ${{ steps.changelog.outputs.summary }} + + draft: false + prerelease: false + + # Publish + - name: Setup credentials + if: steps.shouldRelease.outputs.value == 'yes' + run: | + mkdir -p ~/.pub-cache + cat < ~/.pub-cache/credentials.json + ${{ secrets.PUB_CREDENTIALS }} + EOF + + - name: Publish package + if: steps.shouldRelease.outputs.value == 'yes' + run: pub publish -f diff --git a/CHANGELOG.md b/CHANGELOG.md index 54f3096..6680055 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 0.2.3 (2021-04-03) + +## Features + +- curent_version command ([ce26035](commit/ce26035)) +- remote_tag_id command ([090a5fd](commit/090a5fd)) + # 0.2.2 (2021-04-02) ## Features diff --git a/pubspec.yaml b/pubspec.yaml index 90f0fa2..75c0e57 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: release_tools description: A collection of scripts to help with creating releases and publishing libraries. -version: 0.2.2 +version: 0.2.3 homepage: https://github.com/asartalo/release_tools environment: