diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 0000000..85905c2 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,87 @@ +name: Prepare Release + +permissions: + contents: write + pull-requests: write + +on: + workflow_dispatch: + inputs: + level: + description: 'Specify SemVer version level you wish to bump (see: https://github.com/crate-ci/cargo-release/blob/master/docs/reference.md#bump-level)' + required: true + type: choice + options: + - release + - patch + - minor + - major + - alpha + - beta + - rc + +jobs: + prepare-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Use Rust version from rust-toolchain.toml + run: rustup show + + - uses: cargo-bins/cargo-binstall@main + + - name: Install dependencies + run: cargo binstall cargo-release -y + + - name: Set up git config + run: | + git config author.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" + git config author.name "${{ github.event.sender.login }}" + git config committer.email "41898282+github-actions[bot]@users.noreply.github.com" + git config committer.name "GitHub Actions Bot" + git config user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" + git config user.name "${{ github.event.sender.login }}" + + - name: Determine new version number by dry-running `cargo-release` + run: | + NEW_VERSION="$( + cargo release version ${{ inputs.level }} 2>&1 \ + | grep "Upgrading .* from .* to .*" \ + | awk '{print $6}' \ + )" + echo "New version is $NEW_VERSION" + echo "NEW_VERSION=$NEW_VERSION" >> "$GITHUB_ENV" + + - name: Switch to the release branch + run: | + BRANCH_NAME="release/v${{ env.NEW_VERSION }}" + git switch -c "$BRANCH_NAME" + + - name: Roll changelog, bump version, and push branch + run: | + # see https://opensource.axo.dev/cargo-dist/book/workspaces/cargo-release-guide.html#using-cargo-release-with-pull-requests + cargo release "${{ inputs.level }}" --execute --no-confirm --config prepare-release.toml + + - name: Open the release PR + env: + GH_TOKEN: ${{ github.token }} + run: | + TITLE="chore(release): prepare release ${{ env.NEW_VERSION }}" + + cat >BODY.md < + +## [Unreleased] - ReleaseDate - Added `dfx` mode, which selects a dfx version and dispatches execution to it. - Added `dfxvm install` command, which installs a dfx version. @@ -13,3 +15,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `dfxvm update` command, which sets the latest dfx version as the default. - Added `dfxvm uninstall` command, which uninstalls a dfx version. - Added `dfxvm list` command, which lists all installed dfx versions. + + +[Unreleased]: https://github.com/dfinity/dfxvm/compare/828e4ed...HEAD diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 69b64b5..cb66959 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,5 +17,26 @@ this in-code documentation must be mirrored by a corresponding change in `docs/cli-reference`. Finally, any feature or notable bugfix should be mentioned in [CHANGELOG.md](CHANGELOG.md), under the `## Unreleased` header. +## Release Process + +Prerequisites to make a release: +```bash +cargo install cargo-release +cargo install cargo-dist +``` + +To make a release, follow these steps: +1. Run the [Prepare Release][prepare-release-workflow] workflow. +2. Obtain approval and merge the PR that the workflow generated. +3. Run the following locally: + +```bash +git checkout main +git pull +cargo dist plan +cargo release --execute +``` + [code-of-conduct]: https://github.com/dfinity/ic-docutrack/blob/main/.github/CODE_OF_CONDUCT.md [cla]: https://github.com/dfinity/cla/blob/master/CLA.md +[prepare-release-workflow]: https://github.com/dfinity/dfxvm/actions/workflows/prepare-release.yml diff --git a/Cargo.toml b/Cargo.toml index db8958c..1e1d66c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ authors = ["DFINITY Stiftung "] description = "dfx version manager" repository = "https://github.com/dfinity/dfxvm" license = "Apache-2.0" +publish = false # don't publish to crates.io # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -55,3 +56,7 @@ targets = ["x86_64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-apple-dar pr-run-mode = "plan" # The archive format to use for non-windows builds (defaults .tar.xz) unix-archive = ".tar.gz" +# In coordination with "publish = false" at the package level, +# this makes `cargo dist` generate binaries for the GitHub release, +# while preventing `cargo release` from publishing to crates.io. +dist = true diff --git a/prepare-release.toml b/prepare-release.toml new file mode 100644 index 0000000..3435cae --- /dev/null +++ b/prepare-release.toml @@ -0,0 +1,10 @@ +pre-release-replacements = [ + {file="CHANGELOG.md", search="Unreleased", replace="{{version}}"}, + {file="CHANGELOG.md", search="\\.\\.\\.HEAD", replace="...v{{version}}", exactly=1}, + {file="CHANGELOG.md", search="ReleaseDate", replace="{{date}}"}, + {file="CHANGELOG.md", search="", replace="\n\n## [Unreleased] - ReleaseDate", exactly=1}, + {file="CHANGELOG.md", search="", replace="\n[Unreleased]: https://github.com/dfinity/dfxvm/compare/v{{version}}...HEAD", exactly=1}, +] +publish = false +tag = false +allow-branch = [ "release/v*" ]