Skip to content

v0.5.0

v0.5.0 #16

# Preamble
name: Create next minor release
on:
release:
types: [released]
# enable worflow to be run manually
workflow_dispatch:
jobs:
get-environment-variables:
outputs:
release-version: ${{ steps.job-outputs-step.outputs.release-version }}
new-release-version: ${{ steps.job-outputs-step.outputs.new-release-version }}
minor-version: ${{ steps.job-outputs-step.outputs.minor-version }}
milestone-number: ${{ steps.job-outputs-step.outputs.milestone-number }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Get most recent release version
run: |
echo "RELEASE_VERSION=$(gh api repos/${{ github.repository }}/tags --jq '.[0] | .name')" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Increment minor version
run: |
IFS='.' read -ra arr <<< ${{ env.RELEASE_VERSION }}
MINOR_VERSION=$((${arr[1]}+1))
arr[1]=$MINOR_VERSION
NEW_RELEASE_VERSION="${arr[0]}.${arr[1]}.${arr[2]}"
echo "MINOR_VERSION="$MINOR_VERSION >> $GITHUB_ENV
echo "NEW_RELEASE_VERSION="$NEW_RELEASE_VERSION >> $GITHUB_ENV
- name: "Check for existing ${{ env.NEW_RELEASE_VERSION }} draft release"
run: |
RELEASES=$(gh api repos/${{ github.repository }}/releases \
-H "Authorize: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X GET \
--jq '.[] | .name')
if [[ $RELEASES =~ ${{ env.NEW_RELEASE_VERSION }} ]]
then
echo "Release exists"
else
gh api repos/${{ github.repository }}/releases \
-H "Authorize: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X POST \
-F name=${{ env.NEW_RELEASE_VERSION }} \
-F tag_name=${{ env.NEW_RELEASE_VERSION }} \
-F draft=true
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Check for existing ${{ env.NEW_RELEASE_VERSION }} milestone"
run: |
MILESTONES=$(gh api repos/${{ github.repository }}/milestones \
-H "Authorize: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X GET \
--jq '.[] | .title')
if [[ $MILESTONES =~ ${{ env.NEW_RELEASE_VERSION }} ]]
then
echo "Milestone exists"
else
gh api repos/${{ github.repository }}/milestones \
-H "Authorize: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X POST \
-F title=${{ env.NEW_RELEASE_VERSION }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Get milestone number for ${{ env.NEW_RELEASE_VERSION }}"
run: |
mapfile -t MILESTONE_NAMES < <(gh api repos/${{ github.repository }}/milestones \
-H "Authorize: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X GET \
--jq '.[] | .title')
mapfile -t MILESTONE_NUMBERS < <(gh api repos/${{ github.repository }}/milestones \
-H "Authorize: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-X GET \
--jq '.[] | .number')
for i in ${!MILESTONE_NAMES[@]}
do
if [[ ${MILESTONE_NAMES[$i]} == ${{ env.NEW_RELEASE_VERSION }} ]]
then
INDEX=$i
fi
done
echo "MILESTONE_NUMBER="${MILESTONE_NUMBERS[$INDEX]} >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get job outputs
id: job-outputs-step
run: |
echo "::set-output name=release-version::${{ env.RELEASE_VERSION }}"
echo "::set-output name=minor-version::${{ env.MINOR_VERSION }}"
echo "::set-output name=new-release-version::${{ env.NEW_RELEASE_VERSION }}"
echo "::set-output name=milestone-number::${{ env.MILESTONE_NUMBER }}"
make-next-version-inital-pr:
needs: get-environment-variables
env:
RELEASE_VERSION: ${{ needs.get-environment-variables.outputs.release-version }}
NEW_RELEASE_VERSION: ${{ needs.get-environment-variables.outputs.new-release-version }}
MINOR_VERSION: ${{ needs.get-environment-variables.outputs.minor-version }}
MILESTONE_NUMBER: ${{ needs.get-environment-variables.outputs.milestone-number }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: master
- name: "Make initial changes for ${{ env.NEW_RELEASE_VERSION }}"
run: |
echo "Update version.py"
sed -i "s/_version_micro = '*[0-9]*'*/_version_micro = ''/g" saltproc/version.py
sed -i "s/_version_minor = [0-9]*/_version_minor = ${{ env.MINOR_VERSION }}/g" saltproc/version.py
sed -i "s/^# _version_extra = 'dev'/_version_extra = 'dev'/g" saltproc/version.py
sed -i "s/^_version_extra = '0'/# _version_extra = '0'/g" saltproc/version.py
echo "Create new release notes"
cp doc/releasenotes/template.rst doc/releasenotes/${{ env.NEW_RELEASE_VERSION }}.rst
sed -i "s/vx.x.x/${{ env.NEW_RELEASE_VERSION }}/g" doc/releasenotes/${{ env.NEW_RELEASE_VERSION }}.rst
sed -i "s/${{ env.RELEASE_VERSION }}/${{ env.NEW_RELEASE_VERSION }}\n ${{ env.RELEASE_VERSION }}/g" doc/releasenotes/index.rst
- name: "Create PR containing inital changes for ${{ env.NEW_RELEASE_VERSION }}"
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: master
add-paths: |
saltproc/version.py
doc/releasenotes/${{ env.NEW_RELEASE_VERSION }}.rst
doc/releasenotes/index.rst
branch: "${{ env.NEW_RELEASE_VERSION }}-init"
delete-branch: true
commit-message: "inital changes for ${{ env.NEW_RELEASE_VERSION }}"
title: "[INIT] Update `version.py` and create release notes for version ${{ env.NEW_RELEASE_VERSION }}"
body: "This is an automated PR that updates the version number and creates the release notes file for version ${{ env.NEW_RELEASE_VERSION }}. This should be the first PR merged during development of version ${{ env.NEW_RELEASE_VERSION }}"
reviewers: yardasol
milestone: ${{ env.MILESTONE_NUMBER }}
labels: |
Priority:1-Critical
Status:5-In Review
Type:Style
Type:Docs
Difficulty:1-Beginner
Comp:Build
make-next-version-final-pr:
needs: [get-environment-variables, make-next-version-inital-pr]
env:
NEW_RELEASE_VERSION: ${{ needs.get-environment-variables.outputs.new-release-version }}
MILESTONE_NUMBER: ${{ needs.get-environment-variables.outputs.milestone-number }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: master
- name: Get changes from the INIT PR
run: |
git pull origin ${{ env.NEW_RELEASE_VERSION }}-init
- name: "Make changes necessary for publishing ${{ env.NEW_RELEASE_VERSION }} in advance"
run: |
echo "Prepare for full release"
sed -i "s/\.\. note:: These release notes are currently in production\.//g" doc/releasenotes/${{ env.NEW_RELEASE_VERSION }}.rst
sed -i "s/^_version_extra = 'dev'/# _version_extra = 'dev'/g" saltproc/version.py
sed -i "s/# _version_extra = '0'/_version_extra = '0'/g" saltproc/version.py
- name: "Create PR containing changes necessary for publishing ${{ env.NEW_RELEASE_VERSION }}"
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: master
add-paths: |
saltproc/version.py
doc/releasenotes/${{ env.NEW_RELEASE_VERSION }}.rst
doc/releasenotes/index.rst
branch: "${{ env.NEW_RELEASE_VERSION }}-final"
delete-branch: true
commit-message: "final changes before publishing ${{ env.NEW_RELEASE_VERSION }}"
title: "[REQUIRED FOR PUBLISHING] Finishing touches for version ${{ env.NEW_RELEASE_VERSION }}"
body: "This is an automated PR that updates the version number and release notes in preparation for the full release of version ${{ env.NEW_RELEASE_VERSION }}. This should be last PR merged before publishing version ${{ env.NEW_RELEASE_VERSION }}. Rebasing this PR on top of the most recent commit in `master` is a prequisite of publishing version ${{ env.NEW_RELEASE_VERSION }}. We rebase becasue the commits in this PR were created around the same time development on ${{ env.NEW_RELEASE_VERSION }} began."
reviewers: yardasol
milestone: ${{ env.MILESTONE_NUMBER }}
labels: |
Priority:2-Normal
Status:1-New
Type:Style
Type:Docs
Difficulty:1-Beginner
Comp:Build