-
Notifications
You must be signed in to change notification settings - Fork 14
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
Automatically generates release note and binaries on release #126
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9f35685
add the feature of automated release note creation
torao 7624080
fix the pattern of tags to action
torao 19b4853
change to create document for release notes from RELEASE_NOTE.md.
torao c1f1061
Merge branch 'main' into feature/prepare_release_binaries
torao 83098af
create Dockerfile due to unknown license
torao 23cf5ff
Merge branch 'feature/prepare_release_binaries' of github.com:torao/l…
torao e18e4bb
remove buildlib.sh due to unknown license
torao 618ebce
change to create release note with cat in github actions
torao bead4a9
fix changelog
torao 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 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,102 @@ | ||
name: "Release Build" | ||
|
||
on: | ||
push: | ||
tags: # Push events to matching v*, i.e. v20.15.10, v0.1.2-rc34 | ||
- "v[0-9]+.[0-9]+.[0-9]+" | ||
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" | ||
|
||
jobs: | ||
build: | ||
name: "Create Release" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout code" | ||
uses: actions/[email protected] | ||
- name: set tag env | ||
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
- name: install go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.18' | ||
check-latest: true | ||
- name: "Build lbm/build-artifacts Docker image" | ||
run: cd builders/build-artifacts && docker build -t lbm/build-artifacts . | ||
- name: "Build artifacts" | ||
run: make distclean build-reproducible | ||
- name: "Generate release note" | ||
run: cat ./RELEASE_NOTE.md <(echo) <(echo '```') ./artifacts/build_report <(echo '```') > ./releasenote | ||
- name: "Create release" | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
body_path: ./releasenote | ||
draft: true | ||
prerelease: false | ||
- name: "Upload build_report" | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./artifacts/build_report | ||
asset_name: build_report | ||
asset_content_type: application/file | ||
# - name: "Upload darwin-amd64 artifact" | ||
# uses: actions/upload-release-asset@v1 | ||
# env: | ||
# GITHUB_TOKEN: ${{ github.token }} | ||
# with: | ||
# upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
# asset_path: ./artifacts/lbm-${{ env.VERSION }}-darwin-amd64 | ||
# asset_name: lbm-${{ env.VERSION }}-darwin-amd64 | ||
# asset_content_type: application/binary | ||
# - name: "Upload darwin-arm64 artifact" | ||
# uses: actions/upload-release-asset@v1 | ||
# env: | ||
# GITHUB_TOKEN: ${{ github.token }} | ||
# with: | ||
# upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
# asset_path: ./artifacts/lbm-${{ env.VERSION }}-darwin-arm64 | ||
# asset_name: lbm-${{ env.VERSION }}-darwin-arm64 | ||
# asset_content_type: application/binary | ||
- name: "Upload linux-amd64 artifact" | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./artifacts/lbm-${{ env.VERSION }}-linux-amd64 | ||
asset_name: lbm-${{ env.VERSION }}-linux-amd64 | ||
asset_content_type: application/binary | ||
# - name: "Upload linux-arm64 artifact" | ||
# uses: actions/upload-release-asset@v1 | ||
# env: | ||
# GITHUB_TOKEN: ${{ github.token }} | ||
# with: | ||
# upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
# asset_path: ./artifacts/lbm-${{ env.VERSION }}-linux-arm64 | ||
# asset_name: lbm-${{ env.VERSION }}-linux-arm64 | ||
# asset_content_type: application/binary | ||
# - name: "Upload windows-amd64 artifact" | ||
# uses: actions/upload-release-asset@v1 | ||
# env: | ||
# GITHUB_TOKEN: ${{ github.token }} | ||
# with: | ||
# upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
# asset_path: ./artifacts/lbm-${{ env.VERSION }}-windows-amd64.exe | ||
# asset_name: lbm-${{ env.VERSION }}-windows-amd64.exe | ||
# asset_content_type: application/binary | ||
- name: "Upload compressed repository" | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./artifacts/lbm-${{ env.VERSION }}.tgz | ||
asset_name: lbm-${{ env.VERSION }}.tgz | ||
asset_content_type: application/gzip |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/bash | ||
|
||
# NOTE: This script is used by lbm/build-artifact Docker container to build release binaries for the platforms listed | ||
# in TARGET_PLATFORMS. If you want to build locally, please run `make distclean build-reproducible` instead of using | ||
# this directly. | ||
|
||
set -ue | ||
|
||
# Expect the following envvars to be set: | ||
# - APP | ||
# - VERSION | ||
# - COMMIT | ||
# - TARGET_PLATFORMS | ||
# - LEDGER_ENABLED | ||
# - DEBUG | ||
|
||
BASEDIR="$(mktemp -d)" | ||
BASENAME="${APP}-${VERSION}" | ||
|
||
OUTDIR="${HOME}/artifacts" | ||
rm -rfv ${OUTDIR}/ | ||
mkdir -p ${OUTDIR}/ | ||
|
||
FILE_EXT="" | ||
if [ $(go env GOOS) = windows ] | ||
then | ||
FILE_EXT=".exe" | ||
fi | ||
|
||
# Prepare a taball for release. | ||
TARBALL="${BASEDIR}/${BASENAME}.tgz" | ||
git archive --format=tar --prefix "${BASENAME}/" HEAD | gzip -9n > "${TARBALL}" | ||
|
||
# Setup a directory to build from the taball. | ||
BUILDDIR="${BASEDIR}/build" | ||
mkdir -p ${BUILDDIR} | ||
cd ${BUILDDIR} | ||
tar zxf "${TARBALL}" --strip-components=1 | ||
go mod download | ||
|
||
# Add the tarball to artifacts | ||
mv "${TARBALL}" "${OUTDIR}" | ||
|
||
setup_env(){ | ||
local PLATFORM="$1" | ||
_GOOS="$(go env GOOS)" | ||
_GOARCH="$(go env GOARCH)" | ||
# slash-separated identifiers such as linux/amd64 | ||
go env -w GOOS="${PLATFORM%%/*}" | ||
go env -w GOARCH="${PLATFORM##*/}" | ||
} | ||
|
||
restore_env() { | ||
go env -w GOOS="${_GOOS}" | ||
go env -w GOARCH="${_GOARCH}" | ||
unset _GOOS | ||
unset _GOARCH | ||
} | ||
|
||
# Build for each os-architecture pair | ||
for platform in ${TARGET_PLATFORMS} ; do | ||
# This function sets GOOS, GOARCH, and FILE_EXT environment variables | ||
# according to the build target platform. FILE_EXT is empty in all | ||
# cases except when the target platform is 'windows'. | ||
setup_env "${platform}" | ||
|
||
make clean | ||
echo Building for $(go env GOOS)/$(go env GOARCH) >&2 | ||
GOROOT_FINAL="$(go env GOROOT)" \ | ||
make build \ | ||
LDFLAGS=-buildid=${VERSION} \ | ||
VERSION=${VERSION} \ | ||
COMMIT=${COMMIT} \ | ||
LEDGER_ENABLED=${LEDGER_ENABLED} | ||
mv ./build/${APP}${FILE_EXT} ${OUTDIR}/${BASENAME}-$(go env GOOS)-$(go env GOARCH)${FILE_EXT} | ||
|
||
# This function restore the build environment variables to their | ||
# original state. | ||
restore_env | ||
done | ||
|
||
# Generate and display build report. | ||
REPORT_FILE="$(mktemp)" | ||
pushd "${OUTDIR}" | ||
cat > "${REPORT_FILE}" <<EOF | ||
App: ${APP} | ||
Version: ${VERSION} | ||
Commit: ${COMMIT} | ||
EOF | ||
echo "Files:" >> "${REPORT_FILE}" | ||
md5sum * | sed 's/^/ /' >> "${REPORT_FILE}" | ||
echo 'Checksums-Sha256:' >> "${REPORT_FILE}" | ||
sha256sum * | sed 's/^/ /' >> "${REPORT_FILE}" | ||
popd | ||
mv "${REPORT_FILE}" "${OUTDIR}/build_report" | ||
cat "${OUTDIR}/build_report" |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# LBM Release Note | ||
|
||
This is a sample release note. If you see this message in the release note, please ensure that `./RELEASE_NOTE.md` is written correctly. | ||
zemyblue marked this conversation as resolved.
Show resolved
Hide resolved
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM golang:1.18.9-bullseye | ||
|
||
RUN apt update && \ | ||
apt upgrade && \ | ||
apt install -y \ | ||
build-essential | ||
|
||
RUN mkdir /lbm | ||
RUN useradd -ms /bin/bash -U lbm | ||
USER lbm:lbm | ||
WORKDIR /lbm | ||
|
||
ENV APP ${APP:-simd} | ||
ENV DEBUG ${DEBUG} | ||
ENV VERSION unknown | ||
ENV COMMIT unknown | ||
ENV LEDGER_ENABLED true | ||
ENV TARGET_PLATFORMS ${TARGET_PLATFORMS:-linux/amd64} | ||
|
||
VOLUME [ "/lbm" ] | ||
ENTRYPOINT [ "/bin/bash" ] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Docker images for creating release builds | ||
|
||
This Docker image is used to create release binaries for Github Actions. To build locally, use the following `make` command: | ||
|
||
`make distclean build-reproducible` | ||
|
||
This will build the build release binaries into `. /artifact`. |
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.
Do you know why it failed in this case?
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.
So far I’ve confirmed that
linux/arm64
produces the following assembler-level error, but I haven’t yet investigated the reason for it.