mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
ci: automated release workflow (#987)
Co-authored-by: jthegedus <jthegedus@users.noreply.github.com>
This commit is contained in:
parent
0d956635b5
commit
60e0e05a9f
24
.github/workflows/docs.yml
vendored
Normal file
24
.github/workflows/docs.yml
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
name: Docs
|
||||||
|
|
||||||
|
on:
|
||||||
|
create:
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bump-version-in-docs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
name: checkout repo
|
||||||
|
with:
|
||||||
|
ref: "refs/heads/master"
|
||||||
|
|
||||||
|
- run: sed -i "s|^\\(git clone.*--branch \\).*$|\\1v$(cat version.txt)|" docs/core-manage-asdf.md
|
||||||
|
name: replace version in docs
|
||||||
|
|
||||||
|
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
|
name: commit docs version update
|
||||||
|
with:
|
||||||
|
commit_message: "docs: update version in install instructions"
|
16
.github/workflows/release.yml
vendored
Normal file
16
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: GoogleCloudPlatform/release-please-action@v2
|
||||||
|
name: create release
|
||||||
|
with:
|
||||||
|
release-type: simple
|
||||||
|
bump-minor-pre-major: true # remove this to enable breaking changes causing 1.0.0 tag
|
18
.github/workflows/semantic-pr.yml
vendored
Normal file
18
.github/workflows/semantic-pr.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
name: Lint PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- edited
|
||||||
|
- synchronize
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
semantic-pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: amannn/action-semantic-pull-request@v3.4.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
validateSingleCommit: true
|
@ -67,8 +67,7 @@ Alternately, you can clone the whole repo and checkout the latest branch:
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
|
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
|
||||||
cd ~/.asdf
|
git -C ~/.asdf checkout "$(git -C ~/.asdf describe --abbrev=0 --tags)"
|
||||||
git checkout "$(git describe --abbrev=0 --tags)"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### --Homebrew--
|
### --Homebrew--
|
||||||
|
@ -10,7 +10,7 @@ ASDF_DATA_DIR=${ASDF_DATA_DIR:-''}
|
|||||||
|
|
||||||
asdf_version() {
|
asdf_version() {
|
||||||
local version git_rev
|
local version git_rev
|
||||||
version="$(cat "$(asdf_dir)/VERSION")"
|
version="v$(cat "$(asdf_dir)/version.txt")"
|
||||||
if [ -d "$(asdf_dir)/.git" ]; then
|
if [ -d "$(asdf_dir)/.git" ]; then
|
||||||
git_rev="$(git --git-dir "$(asdf_dir)/.git" rev-parse --short HEAD)"
|
git_rev="$(git --git-dir "$(asdf_dir)/.git" rev-parse --short HEAD)"
|
||||||
printf "%s-%s\\n" "$version" "$git_rev"
|
printf "%s-%s\\n" "$version" "$git_rev"
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
# Release README
|
|
||||||
|
|
||||||
If you are a user you can ignore everything in this directory. This directory
|
|
||||||
contains documentation and scripts for preparing and tagging new versions of
|
|
||||||
asdf and is only used by asdf maintainers.
|
|
||||||
|
|
||||||
## Tagging Release Candidates
|
|
||||||
|
|
||||||
To tag release candidates
|
|
||||||
|
|
||||||
1. Update the CHANGELOG. Make sure it contains an entry for the version you are
|
|
||||||
tagging as well as a dev version things that come after the tag (e.g. a heading
|
|
||||||
with the format `<next-version>-dev`).
|
|
||||||
2. Run the tests, linter and format check - `bats test`, `./scripts/shellcheck.bash` and `./scripts/shfmt.bash`.
|
|
||||||
3. Run the release script. The new version must be in the format `0.0.0-rc0`.
|
|
||||||
For example: `release/tag.sh 0.0.0-rc0`.
|
|
||||||
4. If the release script succeeds, push to GitHub. Make sure to use the correct
|
|
||||||
remote to push to the official repository
|
|
||||||
|
|
||||||
## Tagging Releases
|
|
||||||
|
|
||||||
1. Update the CHANGELOG. Make sure it contains an entry for the version you are
|
|
||||||
tagging as well as a dev version things that come after the tag (e.g. a heading
|
|
||||||
with the format `<next-version>-dev`).
|
|
||||||
2. Run the tests, linter and format check - `bats test`, `./scripts/shellcheck.bash` and `./scripts/shfmt.bash`.
|
|
||||||
3. Run the release script. The new version must be in the format `0.0.0`. For
|
|
||||||
example: `release/tag.sh 0.0.0`.
|
|
||||||
4. If the release script succeeds, push to GitHub. Make sure to use the correct
|
|
||||||
remote to push to the official repository
|
|
130
release/tag.sh
130
release/tag.sh
@ -1,130 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Unoffical Bash "strict mode"
|
|
||||||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
|
|
||||||
set -euo pipefail
|
|
||||||
#ORIGINAL_IFS=$IFS
|
|
||||||
IFS=$'\t\n' # Stricter IFS settings
|
|
||||||
|
|
||||||
# shellcheck disable=SC2006
|
|
||||||
usage() {
|
|
||||||
cat <<EOF
|
|
||||||
|
|
||||||
Usage: tag.sh [new version]
|
|
||||||
|
|
||||||
This script is only intended for use by asdf maintainers when releasing new
|
|
||||||
versions of asdf. Plugin developers and asdf users do not need this script.
|
|
||||||
|
|
||||||
This script updates the hardcoded versions in the source code and README and
|
|
||||||
then commits them on the current branch. It then tags that commit with the
|
|
||||||
specified version.
|
|
||||||
|
|
||||||
If you run this script in error, or with the wrong version, you can undo the
|
|
||||||
changes by finding the original state in the list of actions listed in the
|
|
||||||
reflog:
|
|
||||||
|
|
||||||
git reflog
|
|
||||||
|
|
||||||
Then revert to the original state by running $(git checkout) with the reference
|
|
||||||
previous to the release tagging changes:
|
|
||||||
|
|
||||||
git checkout HEAD@{21}
|
|
||||||
|
|
||||||
Then checkout the original branch again:
|
|
||||||
|
|
||||||
git checkout master
|
|
||||||
|
|
||||||
You are back to the original state!
|
|
||||||
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
error_exit() {
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
new_version="${1:-}"
|
|
||||||
new_tag_name="v$new_version"
|
|
||||||
|
|
||||||
# Make sure the user provides a version
|
|
||||||
if [[ -z "$new_version" ]]; then
|
|
||||||
echo "ERROR: no new version specified"
|
|
||||||
error_exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Make sure version passed in is a plain semantic version to guard against
|
|
||||||
# leading 'v'.
|
|
||||||
if ! [[ "${new_version:0:1}" =~ ^[0-9]+$ ]]; then
|
|
||||||
echo >&2 "ERROR: semantic version should not start with a letter"
|
|
||||||
error_exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Make sure the version the user provided hasn't already been tagged
|
|
||||||
if git tag | grep "^$new_tag_name$" >/dev/null; then
|
|
||||||
echo >&2 "ERROR: git tag with that version already exists"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If not a release candidate version
|
|
||||||
if ! (echo "$new_version" | grep -i "rc"); then
|
|
||||||
# Make sure an RC already exists when tagging a major or minor version
|
|
||||||
new_major_and_minor=$(echo "$new_version" | cut -d. -f1,2)
|
|
||||||
if ! git tag | grep "^v$new_major_and_minor.[0-9]*$" >/dev/null; then
|
|
||||||
# If the major and minor versions don't already exist, make sure this release
|
|
||||||
# is preceded by an RC release
|
|
||||||
if ! git tag | grep "^v$new_major_and_minor.[0-9]*-rc[0-9]*$" >/dev/null; then
|
|
||||||
echo >&2 "ERROR: New major and minor versions must be preceded by an RC version"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Make sure the changelog already contains details on the new version
|
|
||||||
if ! grep "$new_version$" CHANGELOG.md; then
|
|
||||||
echo >&2 "ERROR: changelog entry for this version is missing"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Make sure the changelog doesn't contain duplicate issue numbers
|
|
||||||
nonunique_issue_numbers=$(grep -o -P '#[\d]+' CHANGELOG.md | sort)
|
|
||||||
unique_issue_numbers=$(grep -o -P '#[\d]+' CHANGELOG.md | sort -u)
|
|
||||||
if [ "$nonunique_issue_numbers" != "$unique_issue_numbers" ]; then
|
|
||||||
echo >&2 "ERROR: Duplicate issue numbers in changelog."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "INFO: Checking that all changes are commited and pushed"
|
|
||||||
git pull
|
|
||||||
|
|
||||||
# Disallow unstaged changes in the working tree
|
|
||||||
if ! git diff-files --check --exit-code --ignore-submodules -- >&2; then
|
|
||||||
echo >&2 "ERROR: You have unstaged changes."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Disallow uncommitted changes in the index
|
|
||||||
if ! git diff-index --cached --exit-code -r --ignore-submodules HEAD -- >&2; then
|
|
||||||
echo >&2 "ERROR: Your index contains uncommitted changes."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update version in docs/core-manage-asdf.md
|
|
||||||
sed -i.bak "s|^\\(git clone.*--branch \\).*$|\\1$new_tag_name|" docs/core-manage-asdf.md
|
|
||||||
rm docs/core-manage-asdf.md.bak
|
|
||||||
|
|
||||||
# Update version in the VERSION file
|
|
||||||
echo "$new_tag_name" >VERSION
|
|
||||||
|
|
||||||
echo "INFO: Committing and tagging new version"
|
|
||||||
|
|
||||||
# Commit the changed files before tagging the new release
|
|
||||||
git add README.md
|
|
||||||
git add docs/core-manage-asdf.md
|
|
||||||
git add VERSION
|
|
||||||
git commit -m "Update version to $new_version"
|
|
||||||
|
|
||||||
git tag -a "$new_tag_name" -m "Version ${new_version}"
|
|
||||||
|
|
||||||
echo "INFO: done."
|
|
||||||
echo "INFO: Now you can push this local branch to the GitHub repository: \`git push <remote> master $new_tag_name\`"
|
|
@ -7,7 +7,6 @@ exec shellcheck -s bash -x \
|
|||||||
bin/private/asdf-exec \
|
bin/private/asdf-exec \
|
||||||
lib/utils.bash \
|
lib/utils.bash \
|
||||||
lib/commands/*.bash \
|
lib/commands/*.bash \
|
||||||
release/tag.sh \
|
|
||||||
scripts/*.bash \
|
scripts/*.bash \
|
||||||
test/test_helpers.bash \
|
test/test_helpers.bash \
|
||||||
test/fixtures/dummy_plugin/bin/*
|
test/fixtures/dummy_plugin/bin/*
|
||||||
|
1
version.txt
Normal file
1
version.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
0.8.1
|
Loading…
Reference in New Issue
Block a user