Skip to content
This repository has been archived by the owner on Sep 2, 2019. It is now read-only.

Commit

Permalink
Add ability to release via a magic tag
Browse files Browse the repository at this point in the history
Not documentated yet. Leaving the previous release process code in
place for now.
  • Loading branch information
SeanTAllen committed Aug 4, 2019
1 parent c1410e6 commit 6b9745c
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 4 deletions.
81 changes: 81 additions & 0 deletions .ci-scripts/release.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

set -o errexit
set -o nounset

USERNAME="{USERNAME}"
REPO="{REPO}"
GITHUB_USER="{GITHUB_USER}"

# Who we are for git
git config --global user.email "{COMMIT_EMAIL}"
git config --global user.name "{COMMIT_NAME}"
git config --global push.default simple

TAG=$1
GITHUB_TOKEN=$2
# changes tag from "release-1.0.0" to "1.0.0"
VERSION="${TAG/release-/}"

### this doesn't account for master changing commit, assumes we are HEAD
# or can otherwise push without issue. that shouldl error out without issue.
# leaving us to restart from a different HEAD commit
# update CHANGELOG
changelog-tool release "${VERSION}" -e

# commit CHANGELOG updates
git add CHANGELOG.md
git commit -m "Release ${VERSION}"

# tag release
git tag "${VERSION}"

# push to release to remote
git push origin master "${VERSION}"

# update CHANGELOG for new entries
changelog-tool unreleased -e

# commit changelog and push to master
git add CHANGELOG.md
git commit -m "Add unreleased section to CHANGELOG post ${VERSION} release
[skip ci]"
git push origin master

# release body
echo "Preparing to update GitHub release notes..."

body=$(changelog-tool get "${VERSION}")

jsontemplate="
{
\"tag_name\":\$version,
\"name\":\$version,
\"body\":\$body
}
"

json=$(jq -n \
--arg version "$VERSION" \
--arg body "$body" \
"${jsontemplate}")

echo "Uploading release notes..."

result=$(curl -X POST "https://api.github.com/repos/${USERNAME}/${REPO}/releases" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "${GITHUB_USER}:${GITHUB_TOKEN}" \
--data "${json}")

rslt_scan=$(echo "${result}" | jq -r '.id')
if [ "$rslt_scan" != null ]
then
echo "Release notes uploaded"
else
echo "Unable to upload release notes, here's the curl output..."
echo "${result}"
exit 1
fi


6 changes: 3 additions & 3 deletions .ci-scripts/upload-release-documentation-to-main-actor.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
set -eu

# Needs to be supplied
USERNAME={USERNAME}
PACKAGE_NAME={PACKAGE}
USERNAME="{USERNAME}"
PACKAGE_NAME="{PACKAGE}"
GITHUB_USER="{GITHUB_USER}"

# Gather expected arguments.
if [ $# -le 2 ]
Expand All @@ -26,7 +27,6 @@ git config --global user.name "{COMMIT_NAME}"
git config --global push.default simple

# Shouldn't need to touch these
GITHUB_USER="${USERNAME}"
BUILD_DIR="build/${PACKAGE_NAME}-docs"
DOCS_DIR="${GEN_MD}/${PACKAGE_NAME}/${TAG}"

Expand Down
17 changes: 17 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ jobs:
- checkout
- run: make test config=debug

cut-release:
docker:
- image: ponylang/main.actor-ci:standard
steps:
- checkout
- run: bash .ci-scripts/release.bash "$CIRCLE-TAG" "${GITHUB_ACCESS_TOKEN_NAME}"

generate-documentation-pr-for-main-dot-actor:
docker:
- image: ponylang/main.actor-ci:standard
Expand All @@ -45,12 +52,22 @@ jobs:

workflows:
version: 2.1

on-every-commit:
jobs:
- verify-changelog
- release-vs-ponyc-release
- debug-vs-ponyc-release

create-release:
jobs:
- cut-release:
filters:
tags:
only: /^release-\d+\.\d+\.\d+$/
branches:
ignore: /.*/

on-release-being-tagged:
jobs:
- generate-documentation-pr-for-main-dot-actor:
Expand Down
3 changes: 2 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Additionally, the CONTRIBUTING.md assumes your project is hosted on GitHub and c

This repository is templated. You'll want to replace anything in {} with the correct value. The following replacement values are required:

- {USERNAME}: your GitHub username, for example: `ponylang`.
- {USERNAME}: your GitHub username or organization name, for example: `ponylang`.
- {REPO}: the name of your repository, for example: `ponyc`.
- {PACKAGE}: the name of your libraries package, for example: `msgpack`.
- {COC_EMAIL}: email address that Code of Conduct violations should be reported to, for example: `[email protected]`.
Expand All @@ -53,6 +53,7 @@ This repository is templated. You'll want to replace anything in {} with the cor
- {COMMIT_NAME}: Name to use for commits that code that is part of this package will create, for example: `ponylang-main`.
- {COMMIT_EMAIL}: Email address to use for commits that code that is part of this package will create, for example: `[email protected]`.
- {GITHUB_ACCESS_TOKEN_NAME}: Name of CircleCI environment variable that your GitHub personal access token that allows for `public_repo` access is stored in.
- {GITHUB_USER}: Username for the owner of the GitHub access token

## What you need to create

Expand Down

0 comments on commit 6b9745c

Please sign in to comment.