-
Notifications
You must be signed in to change notification settings - Fork 50
AZ 219 remove git force push to main #165
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
Changes from 20 commits
4bf02ae
402b6b3
7e03172
753cef5
0d4ff1b
1f9b007
5ae61db
f6eb26d
de09bcf
91e51be
9b29dad
85fde32
36e6263
4ae86fa
a436772
624aad4
c158f4a
56c0308
708aa43
b8df6b4
dc09229
4339e93
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| name: Autobump version on PR | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| prepare-new-version: | ||
| environment: Autobump version | ||
| runs-on: ubuntu-latest | ||
| if: ${{ github.repository == 'Cardinal-Cryptography/AlephBFT'}} | ||
| steps: | ||
| - name: cargo-next-install | ||
| run: | | ||
| cargo install cargo-next --locked | ||
| - name: checkout | ||
| uses: actions/checkout@v2 | ||
| with: | ||
| fetch-depth: 2 | ||
| ref: ${{ github.head_ref }} | ||
| token: ${{ secrets.SYNCAZF || secrets.MY_TOKEN || github.token }} | ||
| - name: check-and-bump | ||
| run: | | ||
| old_version=`cargo next --get` | ||
| # If version on PR branch and main branch have no differences in version -> bump it. | ||
| # Set version in README.md, commit, tag and push to PR branch. | ||
| # Assuming nominal version for us is the one in the top level Cargo.toml. | ||
| if ! git diff ${{ github.head_ref }} ${{ github.base_ref }} -- Cargo.toml | grep -q '^+version ='; then | ||
| echo "Version $old_version has NOT been changed manually between ${{ github.head_ref }} and ${{ github.base_ref }}, patching it now." | ||
| cargo next --patch | ||
| new_version=`cargo next --get` | ||
| echo "New version is $new_version." | ||
| git add Cargo.toml | ||
| fi | ||
| new_version=`cargo next --get` | ||
| # Make sure README has the same version as Cargo.toml. | ||
| sed -i "s/^version = \"$version\"$/version = \"$new_version\"/" Cargo.toml | ||
| git add README.md | ||
| # Publishing changes to PR branch | ||
| git config user.email "<>" | ||
| git config user.name "Version autobump" | ||
| git commit -m "Setting version to $new_version" | ||
timorl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Create tag with version if it not exist. | ||
| if ! git rev-parse "$new_version" >/dev/null 2>&1; then | ||
| git tag -a $new_version -m "Version $new_version created at PR ${{ github.head_ref }} -> ${{ github.base_ref }}" | ||
| fi | ||
| - name: push-to-PR | ||
| run: | | ||
| git push --follow-tags | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,16 @@ | ||
| name: Sync Cardinal-Cryptography repo with Aleph-Zero-Foundation repo | ||
| name: Publish AlephBFT main to crates.io. | ||
timorl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Autobump version"] | ||
| branches: [main] | ||
| types: | ||
| - completed | ||
| # NOTE: changed to "manual workflow dispatch" for now. | ||
| # TODO: To be automated again, when workflows stabilize | ||
| # and pushes to main origin will be forbidden. | ||
| workflow_dispatch: | ||
|
|
||
| # workflow_run: | ||
| # workflows: ["Autobump version"] | ||
| # branches: [main] | ||
| # types: | ||
| # - completed | ||
|
||
|
|
||
| jobs: | ||
| sync: | ||
|
|
@@ -19,3 +24,14 @@ jobs: | |
| token: ${{ secrets.SYNCAZF }} | ||
| - name: Push to Aleph-Zero-Foundation | ||
| run: git push https://x-access-token:${{ secrets.SYNCAZF }}@github.com/aleph-zero-foundation/AlephBFT.git | ||
| - uses: actions-rs/toolchain@v1 | ||
| with: | ||
| toolchain: stable | ||
| - name: credentials | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: login | ||
| args: ${{ secrets.CRATES_IO_TOKEN }} | ||
| - name: publish | ||
| run: | | ||
| cargo publish | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,37 +11,6 @@ jobs: | |
| runs-on: ubuntu-latest | ||
| if: ${{ github.repository == 'Cardinal-Cryptography/AlephBFT'}} | ||
| steps: | ||
| - name: checkout | ||
| uses: actions/checkout@v2 | ||
| with: | ||
| fetch-depth: 2 | ||
| - name: bump | ||
| run: | | ||
| version=`grep -e '^version =' Cargo.toml | sed 's/version = //' | sed 's/"//g'` | ||
| major_version=`echo $version|grep -o -e '^[0-9]*'` | ||
| minor_version=`echo $version|grep -o -e '^[0-9]*.[0-9]*'|grep -o -e '[0-9]*$'` | ||
| patch_version=`echo $version|grep -o -e '[0-9]*$'` | ||
| git config user.email "<>" | ||
| git config user.name "Version autobump" | ||
| if git diff HEAD~ -- Cargo.toml | grep -q '^+version ='; then | ||
| echo 'Version has been bumped manually, bumping readme version and uploading to crates.io' | ||
| new_version=$major_version.$minor_version | ||
| sed -i "s/aleph-bft = \"\^[0-9]*.[0-9]*\"$/aleph-bft = \"^$new_version\"/" README.md | ||
| git add README.md | ||
| git commit --amend --no-edit | ||
| git push -f origin main | ||
| touch publishMe | ||
| exit 0 | ||
| fi | ||
| if [ -e `git diff HEAD~ -- src/` ]; then | ||
| echo 'No changes in code.' | ||
| exit 0 | ||
| fi | ||
| new_version=$major_version.$minor_version.$((patch_version + 1)) | ||
| sed -i "s/^version = \"$version\"$/version = \"$new_version\"/" Cargo.toml | ||
| git add Cargo.toml | ||
| git commit --amend --no-edit | ||
| git push -f origin main | ||
| - uses: actions-rs/toolchain@v1 | ||
| with: | ||
| toolchain: stable | ||
|
|
@@ -52,6 +21,6 @@ jobs: | |
| args: ${{ secrets.CRATES_IO_TOKEN }} | ||
| - name: publish | ||
| run: | | ||
| if [ -f publishMe ]; then | ||
| cargo publish | ||
| fi | ||
| echo 'Uploading to crates.io' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uh, I'm confused now, this always pushes to crates.io? Anyway, you probably want to rename this file? It seems there was some naming confusion here.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This workflow is invoked right now only manually, so yes, if you invoke it manually, it will publish every time it will be called.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused, although maybe it's just my lack of understanding of workflows – this file seems to imply it will always run on push to main, the other file states it only runs manually. And the other one also publishes. Shouldn't this file just be deleted then?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I did some clean up. See 4339e93. Workflow should be like this:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that seems good now. I still have some gripes with naming – maybe call this one something like "Publish to crates.io" rather than "Autobump version"? Similar for file names, what is now called "prepare-..." should just be "version-bump" and this one "publish" or something. |
||
| cargo publish | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this block can be made into sh script (and put somewhere in the
scripts/...folder). This way it will be more readable here and easier to review the script without the noise from the workflow file.