Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: release ci #17

Merged
merged 4 commits into from
Jun 13, 2024
Merged

ci: release ci #17

merged 4 commits into from
Jun 13, 2024

Conversation

tchataigner
Copy link
Contributor

This PR aims to have a proper workflow for the releases of the Light Client workspace.

  1. release.yml: This workflow has to be manually triggered and takes a valid Semver formatted version as an input. It will create a release branhc, bump the Cargo.toml versions for our main crates and create a PR from the release branch on dev
  2. release-merge.yml: This workflow is meant to be triggered when a release branch is merged in main. For now it has one job, creating a tag that will refer to the head of the release branch.

Signed-off-by: Thomas Chataigner <[email protected]>
Signed-off-by: Thomas Chataigner <[email protected]>
@tchataigner tchataigner marked this pull request as ready for review June 13, 2024 16:29
Copy link
Member

@samuelburnham samuelburnham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the e2e flow with the inline fixes and it works pretty well! I think we're on the right track

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
Copy link
Member

@samuelburnham samuelburnham Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this in favor of a shallow checkout?

fetch-depth: 0

- name: Setup Rust
uses: actions-rs/toolchain@v1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is deprecated, we should use dtolnay/rust-toolchain@stable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it as we don't need it anyway

- name: Validate version
run: |
echo "Validating version..."
VERSION_REGEX="^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't working for me, maybe I'm missing something? Repro'd locally with 0.1.0 and 1.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the REGEX, it was for PERL 🤦

run: git push origin release/${{ github.event.inputs.version }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action will check out and commit to the new branch for us, so we can remove the Create release branch and Commit changes steps.

We can also remove the token and base inputs as they are defaults, and update the action to v6

# Regex from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
- name: Validate version
run: |
echo "Validating version..."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Would be nice to print the input version here

id: get-version
run: |
VERSION=$(echo "${{ github.event.pull_request.head.ref }}" | cut -d'/' -f 2)
echo "name=version::${VERSION}" | tee -a $GITHUB_OUTPUT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This format seems to not work with the following actions, I think it may be better to just set name=${VERSION}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



- name: Push tag
uses: laputansoft/[email protected]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Switch to mathiedutour variant as discussed. I noticed the action has automatic tag bumping based on https://github.com/semantic-release/semantic-release, may be worth creating an issue to peruse this later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually removing this step, softprops/action-gh-release@v2 already creates a tag

- name: Create Release
uses: mikepenz/[email protected] #softprops/action-gh-release
with:
body: ${{steps.github_release.outputs.changelog}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add tag_name: ${{ steps.get-version.outputs.name }} as an input for it to work

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
uses: mikepenz/[email protected] #softprops/action-gh-release
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: switch to softprops as discussed

run: |
echo "Validating version..."
VERSION_REGEX="^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
if [[ "${{ github.event.inputs.version }}" =~ $VERSION_REGEX ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: here and elsewhere you can just do ${{ inputs.version }}

Signed-off-by: Thomas Chataigner <[email protected]>
Signed-off-by: Thomas Chataigner <[email protected]>
@tchataigner tchataigner force-pushed the feature/release-workflow branch from 7497abc to fae2d27 Compare June 13, 2024 20:24
@tchataigner tchataigner merged commit a75a2ac into dev Jun 13, 2024
3 checks passed
@tchataigner tchataigner deleted the feature/release-workflow branch June 13, 2024 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants