Skip to content

Commit

Permalink
fix: better release logic
Browse files Browse the repository at this point in the history
  • Loading branch information
asartalo committed Jul 26, 2022
1 parent bb43ada commit 51ae0bf
Showing 1 changed file with 31 additions and 46 deletions.
77 changes: 31 additions & 46 deletions .github/workflows/build.yml
Expand Up @@ -90,84 +90,69 @@ jobs:
- name: Check if pub tools are available
run: which release_tools

- name: Get current version
id: currentVersion
run: echo "::set-output name=value::$(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::$(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::$(release_tools should_release --from ${{ steps.lastCommitId.outputs.value }})"

- run: echo ${{ steps.shouldRelease.outputs.value }}

- name: If we can release, get the next version
if: steps.shouldRelease.outputs.value == 'yes'
id: nextVersion
run: echo "::set-output name=value::$(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
- name: Prepare release
run: |
release_tools update_version ${{ steps.nextVersion.outputs.value }}
release_tools update_version --file="lib/sentinel_version.dart" ${{ steps.nextVersion.outputs.value }}
flutter pub run release_tools prepare_release -w
cat VERSION.txt
- name: Write changelog
id: changelog
if: steps.shouldRelease.outputs.value == 'yes'
- name: Get Release Info
id: releaseInfo
run: |
if [ -e VERSION.txt ]
then
shouldRelease="yes"
releaseVersion=$(cat VERSION.txt)
summary=$(cat RELEASE_SUMMARY.txt)
echo "::set-output name=version::${releaseVersion}"
echo "::set-output name=summary::${summary}"
else
shouldRelease="false"
fi
echo "::set-output name=shouldRelease::${shouldRelease}"
- name: Stop Gap Prepared Release
run: |
output=$(release_tools changelog --from ${{ steps.lastCommitId.outputs.value }} ${{ steps.nextVersion.outputs.value }})
output="${output//'%'/'%25'}"
output="${output//$'\n'/'%0A'}"
output="${output//$'\r'/'%0D'}"
echo "::set-output name=summary::$output"
cat pubspec.yaml
cat VERSION.txt
cat RELEASE_SUMMARY.txt
foo
- name: Commit Release
if: steps.shouldRelease.outputs.value == 'yes'
if: steps.releaseInfo.outputs.shouldRelease == '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 commit -m "chore(release): release for ${{ steps.releaseInfo.outputs.version }}"
git push
- name: Create Release
if: steps.shouldRelease.outputs.value == 'yes'
if: steps.releaseInfo.outputs.shouldRelease == '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 }}
tag_name: ${{ steps.releaseInfo.outputs.version }}
release_name: Release ${{ steps.releaseInfo.outputs.version }}
body: |
Changes in this Release
${{ steps.changelog.outputs.summary }}
${{ steps.releaseInfo.outputs.summary }}
draft: false
prerelease: false

# Publish
- name: Setup credentials
if: steps.shouldRelease.outputs.value == 'yes'
if: steps.releaseInfo.outputs.shouldRelease == 'yes'
run: |
mkdir -p ~/.pub-cache
cat <<EOF > ~/.pub-cache/credentials.json
${{ secrets.PUB_CREDENTIALS }}
EOF
- name: Publish package
if: steps.shouldRelease.outputs.value == 'yes'
if: steps.releaseInfo.outputs.shouldRelease == 'yes'
run: dart pub publish -f

0 comments on commit 51ae0bf

Please sign in to comment.