This repository was archived by the owner on Apr 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
feat(ci): create GitHub release workflow #121
Closed
johnsonshi
wants to merge
2
commits into
openservicemesh:main
from
johnsonshi:create-gh-release-workflow
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
version: | ||
name: Set Version from git ref | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.version.outputs.version }} | ||
steps: | ||
- id: version | ||
run: echo "::set-output name=version::$(sed 's#^refs/tags/\(.*\)#\1#' <<< '${{ github.ref }}')" | ||
|
||
binaries: | ||
name: Binaries | ||
runs-on: ubuntu-latest | ||
needs: version | ||
env: | ||
# VERSION: ${{ needs.version.outputs.version }} | ||
VERSION: v0.0.1 | ||
BUILD_DATE: '$$(date +%Y-%m-%d-%H:%M)' | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Restore Module Cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-gomod2-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-gomod2- | ||
- name: Restore Build Cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/go-build | ||
key: ${{ runner.os }}-gobuild-${{ hashFiles('**/*.go') }} | ||
- name: Setup Go 1.16 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.16 | ||
- name: Build Binaries | ||
run: | | ||
make release-artifacts | ||
- name: Generate Release Notes | ||
run: scripts/release-notes.sh $VERSION > release-notes.md | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
body_path: release-notes.md | ||
prerelease: ${{ contains(env.VERSION, '-alpha.') || contains(env.VERSION, '-beta.') || contains(env.VERSION, '-rc.') || contains(env.VERSION, '-nightly.') }} | ||
- name: Upload macOS .zip | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: "_dist/osm-health-${{ env.VERSION }}-darwin-amd64.zip" | ||
asset_name: "osm-health-${{ env.VERSION }}-darwin-amd64.zip" | ||
asset_content_type: application/zip | ||
- name: Upload macOS .tar.gz | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: "_dist/osm-health-${{ env.VERSION }}-darwin-amd64.tar.gz" | ||
asset_name: "osm-health-${{ env.VERSION }}-darwin-amd64.tar.gz" | ||
asset_content_type: application/gzip | ||
- name: Upload Linux .zip | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: "_dist/osm-health-${{ env.VERSION }}-linux-amd64.zip" | ||
asset_name: "osm-health-${{ env.VERSION }}-linux-amd64.zip" | ||
asset_content_type: application/zip | ||
- name: Upload Linux .tar.gz | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: "_dist/osm-health-${{ env.VERSION }}-linux-amd64.tar.gz" | ||
asset_name: "osm-health-${{ env.VERSION }}-linux-amd64.tar.gz" | ||
asset_content_type: application/gzip | ||
- name: Upload Windows .zip | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: "_dist/osm-health-${{ env.VERSION }}-windows-amd64.zip" | ||
asset_name: "osm-health-${{ env.VERSION }}-windows-amd64.zip" | ||
asset_content_type: application/zip | ||
- name: Upload Windows .tar.gz | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: "_dist/osm-health-${{ env.VERSION }}-windows-amd64.tar.gz" | ||
asset_name: "osm-health-${{ env.VERSION }}-windows-amd64.tar.gz" | ||
asset_content_type: application/gzip | ||
- name: Upload Checksums | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: _dist/sha256sums.txt | ||
asset_name: sha256sums.txt | ||
asset_content_type: text/plain |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Generate release notes using the changes between the given tag and its | ||
# predecessor, calculated by git's version sorting. When a stable tag (i.e. | ||
# without a pre-release tag like alpha, beta, etc.) is provided, then the | ||
# previous tag will be the next latest stable tag, skipping any intermediate | ||
# pre-release tags. | ||
|
||
# This script will break or produce weird output if: | ||
# - Tags are not formatted in a way that can be interpreted by git tag's --sort=version:refname | ||
# - Pre-release tags other than "nightly", "alpha", "beta", and "rc" are used. | ||
|
||
tag=$1 | ||
|
||
# No release notes for nightlies | ||
if [[ "$tag" =~ "nightly" ]]; then | ||
exit 0 | ||
fi | ||
|
||
tags=$(git tag | tr - \~ | sort -V | tr \~ - | sed "/^$tag$/q" ) | ||
! [[ "$tag" =~ -(alpha|beta|rc) ]] && tags=$(grep -Eve '-(alpha|beta|rc)' <<< "$tags") | ||
prev=$(tail -2 <<< "$tags" | head -1) | ||
|
||
changelog=$(git log "$prev".."$tag" --no-merges --format="* %s %H (%aN)") | ||
|
||
cat <<EOF | ||
## Notable Changes | ||
|
||
## Deprecation Notes | ||
|
||
## Changelog | ||
|
||
$changelog | ||
EOF |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out?