Fix #127
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: [push] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
name: Creates a Release for a fast-forwarded release branch | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: ./.github/actions/clean-up-from-tests | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up git config | |
run: | | |
git config --global user.email "github-actions@example.com" | |
git config --global user.name "GitHub Actions" | |
git checkout --orphan develop | |
- run: touch CHANGELOG.md | |
- name: Create a simple CHANGELOG | |
run: | | |
cat > CHANGELOG.md << EOF | |
# Changelog | |
## [Unreleased] | |
### Added | |
- Some `amazing` stuff | |
[Unreleased]: https://github.com/example/repo/v0.0.0...HEAD | |
EOF | |
- name: Commit the CHANGELOG | |
run: | | |
git commit -am "Add a changelog" | |
- name: Create a release in the CHANGELOG | |
uses: cucumber/action-changelog@v1.3 | |
with: | |
args: release --output CHANGELOG.md T.E.S.T | |
- name: Commit the release | |
run: | | |
git commit -am "Release vT.E.S.T" | |
- name: Create a release branch | |
run: | | |
git checkout HEAD^ | |
git checkout -b release/test | |
git merge --ff-only develop | |
git push --set-upstream origin release/test | |
- name: Test the action - attempt to create a Release | |
uses: ./ | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Assert that the Release was created | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
name="vT.E.S.T" | |
release=$(gh release list | grep $name | cut -f1) | |
echo "Release: $release" | |
if [[ -z "$release" ]] | |
then | |
echo "No release created named $name"; | |
exit 1; | |
fi | |
# TODO: Figure out why backticked text disappears - see https://github.com/cucumber/action-create-github-release/issues/3 | |
- name: Assert that the release body is as expected | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
name="vT.E.S.T" | |
expected=$(cat << "END" | |
### Added | |
- Some stuff | |
END | |
) | |
actual=$(gh release view $name --json body --jq ".body") | |
if [[ "$actual" != "$expected" ]]; then | |
echo "expected: \n----$expected\n----" | |
echo "actual: \n----$actual\n----" | |
exit 1 | |
fi | |
- name: Assert that a tag for the release points to the head of `develop` branch | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git fetch --tags | |
expected=$(git rev-parse develop) | |
actual=$(git rev-parse vT.E.S.T) | |
if [[ "$expected" != "$actual" ]]; then | |
echo "Commit $expected not tagged 'vT.E.S.T' as expected" | |
exit 1 | |
fi | |
- uses: ./.github/actions/clean-up-from-tests | |
if: ${{ always() }} | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} |