diff --git a/.github/scripts/changelog.sh b/.github/scripts/changelog.sh new file mode 100755 index 0000000..0b00636 --- /dev/null +++ b/.github/scripts/changelog.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +file="./CHANGELOG.md" +regex='^## \[([0-9]+)\.([0-9]+)\.([0-9]+)\] - ([0-9]{4}-[0-9]{2}-[0-9]{2})$' + +version='' +log=() + +while read line; do + if [[ $line =~ $regex ]]; then + if [[ -z "$version" ]]; then + major="${BASH_REMATCH[1]}" + minor="${BASH_REMATCH[2]}" + patch="${BASH_REMATCH[3]}" + version="$major.$minor.$patch" + date="${BASH_REMATCH[4]}" + else + break + fi + elif [[ ! -z "$version" ]]; then + log+=("$line") + fi +done <<< "$(cat "$file")" diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml new file mode 100644 index 0000000..6e2ce34 --- /dev/null +++ b/.github/workflows/pre-release.yml @@ -0,0 +1,30 @@ +name: Pre Release +on: + pull_request: + paths: [CHANGELOG.md] + branches: [master] +jobs: + Post-Comment: + name: Post Comment + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: | + source .github/scripts/changelog.sh + git fetch origin --tags + if [[ ! -z "$version" && -z "$(git tag -l "v$version")" ]]; then + echo "BODY<> $GITHUB_ENV + echo "$(IFS=$'\n'; echo "${log[*]}")" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + echo "TAG=v$version" >> $GITHUB_ENV + fi + shell: bash + - if: ${{ env.TAG != '' }} + uses: marocchino/sticky-pull-request-comment@82e7a0d3c51217201b3fedc4ddde6632e969a477 # v2.1.1 + with: + header: pre-release + recreate: true + message: | + ## ${{ env.TAG }} + + ${{ env.BODY }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..92c3274 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release +on: + workflow_dispatch: + push: + paths: [CHANGELOG.md] + branches: [master] +jobs: + Publish: + name: Publish + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: | + source .github/scripts/changelog.sh + git fetch origin --tags + if [[ ! -z "$version" && -z "$(git tag -l "v$version")" ]]; then + git tag "v$major.$minor.$patch" + git tag "v$major.$minor" --force + git tag "v$major" --force + git push --tags --force + echo "BODY<> $GITHUB_ENV + echo "$(IFS=$'\n'; echo "${log[*]}")" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + echo "TAG=v$version" >> $GITHUB_ENV + fi + shell: bash + - if: ${{ env.TAG != '' }} + uses: ncipollo/release-action@40bb172bd05f266cf9ba4ff965cb61e9ee5f6d01 # v1.9.0 + with: + body: | + ${{ env.BODY }} + tag: ${{ env.TAG }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b0776dd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0] - 2022-04-14 +### Added +- release workflows +- changelog + +### Changed +- the repository from https://github.com/coryschwartz/testground-github-action to https://github.com/testground/testground-github-action diff --git a/README.md b/README.md index 438add6..d494ba3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +*NOTE*: This repository was forked from https://github.com/coryschwartz/testground-github-action to continue its' active development (initially to include the following fix: https://github.com/coryschwartz/testground-github-action/pull/2). + # testground-github-action Submit jobs to [testground](https://testground.ai) and view the outcome in Github. @@ -27,7 +29,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: ${{ matrix.composition_file }} - id: + id: uses: coryschwartz/testground-github-action@v1.0 with: backend_addr: ${{ matrix.backend_addr }} diff --git a/entrypoint.sh b/entrypoint.sh index e7bd37c..f54f3b1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,6 +37,14 @@ ln -s "${REAL_PLAN_DIR}" "${PLANSHOME}" --metadata-branch "${GITHUB_REF#refs/heads/}" \ --metadata-commit "${GITHUB_SHA}" | tee run.out TGID=$(awk '/run is queued with ID/ {print $10}'