-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflows for bumping versions and releasing (#77)
- Loading branch information
Showing
5 changed files
with
226 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: Publish to pub.dev | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+*" | ||
|
||
jobs: | ||
publish: | ||
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
prepare: | ||
if: github.repository_owner == 'viamrobotics' && startsWith(github.ref_name, 'rc-') | ||
runs-on: [self-hosted, x64] | ||
container: | ||
image: ghcr.io/cirruslabs/flutter:3.10.6 | ||
outputs: | ||
version: ${{ steps.which_version.outputs.version }} | ||
steps: | ||
- name: Check if organization member | ||
id: is_organization_member | ||
uses: jamessingleton/[email protected] | ||
with: | ||
organization: viamrobotics | ||
username: ${{ github.actor }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Cancelling - not an organization member | ||
uses: andymckay/[email protected] | ||
if: steps.is_organization_member.outputs.result == 'false' | ||
|
||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Flutter | ||
run: flutter pub get | ||
|
||
- run: make setup | ||
|
||
- name: Format + Lint + Test | ||
run: make format lint test | ||
|
||
- name: Bump Version | ||
shell: bash | ||
run: PATH=$PATH:$HOME/.pub-cache/bin cider bump release | ||
|
||
- name: Which Version | ||
id: which_version | ||
shell: bash | ||
run: PATH=$PATH:$HOME/.pub-cache/bin echo "version=$(cider version | sed -e 's/\"//g' -e 's/-rc.*//g')" >> $GITHUB_OUTPUT | ||
|
||
- name: Check if release exists | ||
uses: cardinalby/[email protected] | ||
id: release_exists | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
releaseName: v${{ steps.which_version.outputs.version }} | ||
doNotFailIfNotFound: "true" | ||
|
||
- name: Cancelling - release already exists | ||
uses: andymckay/[email protected] | ||
if: steps.release_exists.outputs.id != '' | ||
|
||
- name: Add + Commit | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
new_branch: rc-${{ steps.which_version.outputs.version }} | ||
message: Bump version to ${{ steps.which_version.outputs.version }} | ||
|
||
- name: Open PR | ||
uses: repo-sync/pull-request@v2 | ||
with: | ||
destination_branch: "main" | ||
pr_title: ${{ steps.which_version.outputs.version }} | ||
pr_body: This is an auto-generated PR to merge the rc branch back into main upon successful release. | ||
|
||
release: | ||
needs: [prepare] | ||
if: github.repository_owner == 'viamrobotics' && startsWith(github.ref_name, 'rc-') | ||
runs-on: [self-hosted, x64] | ||
container: | ||
image: ghcr.io/viamrobotics/canon:amd64 | ||
|
||
steps: | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: v${{ needs.prepare.outputs.version }} | ||
draft: true | ||
prerelease: false | ||
target_commitish: rc-${{ needs.prepare.outputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
name: Release Candidate | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "The type of version bump. If the current version is already RC, then the bump type is ignored and only the RC is increased. If nobump is selected, there is no RC increase. Ex: Current Version (CV): 0.0.1, type: patch, result: 0.0.2-rc.1. CV: 0.0.2-rc.1, type: patch, result: 0.0.2-rc.2. See https://github.com/f3ath/cider#bumping-the-project-version" | ||
type: choice | ||
required: true | ||
default: nobump | ||
options: | ||
- major | ||
- minor | ||
- patch | ||
- nobump | ||
|
||
jobs: | ||
prepare: | ||
if: github.repository_owner == 'viamrobotics' | ||
runs-on: [self-hosted, x64] | ||
container: | ||
image: ghcr.io/cirruslabs/flutter:3.10.6 | ||
outputs: | ||
rc_version: ${{ steps.which_version.outputs.rc_version }} | ||
version: ${{ steps.which_version.outputs.version }} | ||
steps: | ||
- name: Check if organization member | ||
id: is_organization_member | ||
uses: jamessingleton/[email protected] | ||
with: | ||
organization: viamrobotics | ||
username: ${{ github.actor }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Cancelling - not an organization member | ||
uses: andymckay/[email protected] | ||
if: steps.is_organization_member.outputs.result == 'false' | ||
|
||
- name: Install GH CLI | ||
run: | | ||
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) | ||
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ | ||
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ | ||
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ | ||
&& sudo apt update \ | ||
&& sudo apt install gh -y | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Flutter | ||
run: flutter pub get | ||
|
||
- run: make setup | ||
|
||
- name: Format + Lint + Test | ||
run: make format lint test | ||
|
||
- name: Current version | ||
id: current_version | ||
shell: bash | ||
run: | | ||
PATH=$PATH:$HOME/.pub-cache/bin echo "current_version=$(cider version)" >> $GITHUB_OUTPUT | ||
- name: Bump Version | ||
id: bump_version | ||
if: inputs.version != 'nobump' | ||
shell: bash | ||
run: | | ||
if ${{ contains(steps.current_version.outputs.current_version, 'rc') }} ; then | ||
PATH=$PATH:$HOME/.pub-cache/bin cider bump pre | ||
else | ||
PATH=$PATH:$HOME/.pub-cache/bin cider bump ${{ inputs.version }} --pre=rc | ||
fi | ||
- name: Which Version | ||
id: which_version | ||
shell: bash | ||
run: | | ||
PATH=$PATH:$HOME/.pub-cache/bin echo "rc_version=$(cider version | sed 's/\"//g')" >> $GITHUB_OUTPUT | ||
PATH=$PATH:$HOME/.pub-cache/bin echo "version=$(cider version | sed -e 's/\"//g' -e 's/-rc.*//g')" >> $GITHUB_OUTPUT | ||
- name: Check if release exists | ||
uses: cardinalby/[email protected] | ||
id: release_exists | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
releaseName: v${{ steps.which_version.outputs.rc_version }} | ||
doNotFailIfNotFound: "true" | ||
|
||
- name: Cancelling - release already exists | ||
uses: andymckay/[email protected] | ||
if: steps.release_exists.outputs.id != '' | ||
|
||
- name: Add + Commit | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
new_branch: rc-${{ steps.which_version.outputs.version }} | ||
message: Bump version to ${{ steps.which_version.outputs.rc_version }} | ||
|
||
- name: Open PR | ||
run: | | ||
gh pr create -t "rc-${{ steps.which_version.outputs.version }}" -b "This is an auto-generated PR to merge the RC branch back into main upon successful release" -B "main" -H "rc-${{ steps.which_version.outputs.version }}" | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
release: | ||
needs: [prepare] | ||
if: github.repository_owner == 'viamrobotics' | ||
runs-on: [self-hosted, x64] | ||
container: | ||
image: ghcr.io/viamrobotics/canon:amd64 | ||
|
||
steps: | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: v${{ needs.prepare.outputs.rc_version }} | ||
draft: true | ||
prerelease: true | ||
target_commitish: rc-${{ needs.prepare.outputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters