Skip to content

Commit

Permalink
CI: Use single packaging job, add changelog support (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrogario authored Feb 22, 2021
1 parent 7f324fa commit 2b70a18
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 36 deletions.
65 changes: 29 additions & 36 deletions .github/workflows/vcpkg_ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
name: VCPKG Continuous Integration

on:
# Run this workflow once every 6 hours against the master branch
schedule:
- cron: "0 */6 * * *"

push:
branches:
- master
- 'master'

tags:
- '*'

pull_request:
schedule:
# run CI every day even if no PRs/merges occur
- cron: '0 6 * * *'
branches:
- '*'

jobs:
build_linux:
Expand Down Expand Up @@ -129,13 +137,25 @@ jobs:
path: ${{ steps.package_names.outputs.TGZ_PACKAGE_PATH }}


release_linux:
release_packages:
# Do not run the release procedure if any of the builds has failed
needs: [ build_linux, build_mac ]
runs-on: ubuntu-20.04
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

steps:
- name: Clone the rellic repository
uses: actions/checkout@v2
with:
path: rellic
fetch-depth: 0

- name: Generate the changelog
shell: bash
working-directory: rellic
run: |
./scripts/generate_changelog.sh changelog.md
- name: Download all artifacts
uses: actions/download-artifact@v2

Expand All @@ -149,6 +169,7 @@ jobs:
with:
tag_name: ${{ github.ref }}
release_name: Version ${{ github.ref }}
body_path: rellic/changelog.md
draft: true
prerelease: true

Expand All @@ -160,6 +181,9 @@ jobs:
zip -r9 rellic_ubuntu-20.04_packages.zip \
ubuntu-20.04*
zip -r9 rellic_macos-10.15_packages.zip \
macos-10.15*
- name: Upload the Ubuntu 18.04 packages
uses: actions/upload-release-asset@v1

Expand All @@ -184,37 +208,6 @@ jobs:
asset_name: rellic_ubuntu-20.04_packages.zip
asset_content_type: application/gzip




release_macos:
# Do not run the release procedure if any of the builds has failed
needs: [ build_linux, build_mac ]
runs-on: 'macos-10.15'
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

steps:
- name: Download all artifacts
uses: actions/download-artifact@v2

- name: Draft the new release
id: create_release
uses: actions/create-release@v1

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

with:
tag_name: ${{ github.ref }}
release_name: Version ${{ github.ref }}
draft: true
prerelease: true

- name: Group the packages by platform
run: |
zip -r9 rellic_macos-10.15_packages.zip \
macos-10.15*
- name: Upload the macOS 10.15 packages
uses: actions/upload-release-asset@v1

Expand Down
30 changes: 30 additions & 0 deletions scripts/generate_changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

PROJECT_NAME="rellic"

main() {
if [[ $# != 1 ]] ; then
printf "Usage:\n\tgenerate_changelog.sh <path/to/changelog/file.md>\n"
return 1
fi

local output_path="${1}"
local current_version="$(git describe --tags --always)"
local previous_version="$(git describe --tags --always --abbrev=0 ${current_version}^)"

echo "Current version: ${current_version}"
echo "Previous version: ${previous_version}"
echo "Output file: ${output_path}"

printf "# Changelog\n\n" > "${output_path}"
printf "The following are the changes that happened between versions ${previous_version} and ${current_version}\n\n" >> "${output_path}"

git log ${previous_version}...${current_version} \
--pretty=format:" * [%h](https://github.com/lifting-bits/${PROJECT_NAME}/commit/%H) - %s" \
--reverse | grep -v 'Merge branch' >> "${output_path}"

return 0
}

main $@
exit $?

0 comments on commit 2b70a18

Please sign in to comment.