Skip to content
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

CI Improvements #1545

Merged
merged 6 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Publish new release"

on:
pull_request:
branches:
- main
types:
- closed
- labeled
jobs:
release:
name: Publish new release
runs-on: ubuntu-latest
if: github.event.pull_request.merged && contains( github.event.pull_request.labels.*.name, 'Release')
steps:
- name: Extract version from branch name (for release branches)
if: startsWith(github.event.pull_request.head.ref, 'release/')
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#release/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Extract version from branch name (for hotfix branches)
if: startsWith(github.event.pull_request.head.ref, 'hotfix/')
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#hotfix/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
- name: Initialize mandatory git config
run: |
git config user.name "GitHub actions"
git config user.email noreply@github.com
- name: Pushing tags
run: |
git tag -a -m "Release v${{ env.RELEASE_VERSION }}" "v${{ env.RELEASE_VERSION }}"
git push origin v${{ env.RELEASE_VERSION }}
- name: Create release
uses: actions/create-release@v1
with:
tag_name: v${{ env.RELEASE_VERSION }}
release_name: Release v${{ env.RELEASE_VERSION }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55 changes: 55 additions & 0 deletions .github/workflows/draft-Release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "Draft new release"

on:
workflow_dispatch:
inputs:
old-version:
description: "Old version"
required: true
new-version:
description: "New version"
required: true

jobs:
draft-new-release:
name: "Draft a new release"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Create release branch
run: git checkout -b release/${{ github.event.inputs.new-version }}
- name: Initialize mandatory git config
run: |
git config user.name "GitHub actions"
git config user.email noreply@github.com
- name: Bump new version in TOML files
run: sh ./scriptBump.sh ${{github.event.inputs.old-version}} ${{github.event.inputs.new-version}}
- name: Commit changelog and manifest files
id: make-commit
run: |

git commit -sa -m "Prepare release ${{ github.event.inputs.new-version }}"
echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Push new branch
run: git push origin release/${{ github.event.inputs.new-version }}

- name: Create pull request
run: gh pr create -B main --title "Release-v${{ github.event.inputs.new-version }}" --body "Yay release" --label "Release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Invoke workflow in tremor-www
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Draft new release
repo: tremor/tremor-www
token: ${{ secrets.PAT_TOKEN }}
inputs: '{ "new-version": "${{ github.event.inputs.new-version }}"}'
- name: Invoke workflow in tremor-language-server
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Draft new release
repo: tremor/tremor-language-server
token: ${{ secrets.PAT_TOKEN }}
inputs: '{ "new-version": "${{ github.event.inputs.new-version }}"}'
53 changes: 53 additions & 0 deletions scriptBump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

TOML_FILES="\
Cargo.toml \
tremor-api/Cargo.toml \
tremor-cli/Cargo.toml \
tremor-common/Cargo.toml \
tremor-influx/Cargo.toml \
tremor-pipeline/Cargo.toml \
tremor-script/Cargo.toml \
tremor-value/Cargo.toml
"
VERSION_TESTS="\
tremor-cli/tests/api-cli/command.yml \
tremor-cli/tests/api/command.yml\
"
DOCKER_FILES="\
Dockerfile.learn\
"
PACKAGES="\
tremor-common \
tremor-value \
tremor-script\
"
old=$1
new=$2

echo -n "Updating TOML files:"
for toml in ${TOML_FILES}
do
echo -n " ${toml}"
sed -e "s/^version = \"${old}\"$/version = \"${new}\"/" -i.release "${toml}"
done
echo "."

echo -n "Updating Version Tests:"
for f in ${VERSION_TESTS}
do
echo -n " ${f}"
sed -e "s/- '{\"version\":\"${old}\"/- '{\"version\":\"${new}\"/" -i.release "${f}"
done
echo "."

echo -n "Updating Docker files:"
for f in ${DOCKER_FILES}
do
echo -n " ${f}"
sed -e "s;^FROM tremorproject/tremor:${old}$;FROM tremorproject/tremor:${new};" -i.release "${f}"
done
echo "."

echo "Updating CHANGELOG.md"
sed -e "s/^## Unreleased$/## ${new}/" -i.release "CHANGELOG.md"