-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[**Part-1] Add github
Release Workflow
#3308
Changes from 4 commits
5192f7d
1b44827
72416f0
aedcf6e
1910f3b
4486728
1dce066
19f00ab
20aef4e
c6eea50
3b909de
ab7aa31
0037cd9
9294c52
c5a8eba
bf29627
37f214f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,270 @@ | ||
name: Release (neo-cli) | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
DOTNET_VERSION: 8.0.x | ||
CONFIGURATION: Release | ||
DIST_PATH: /tmp/dist | ||
OUTPUT_PATH: /tmp/out | ||
|
||
jobs: | ||
build-leveldb: | ||
name: Build leveldb (windows-latest) | ||
runs-on: windows-latest | ||
strategy: | ||
matrix: | ||
arch: [x64, arm64] | ||
|
||
steps: | ||
- name: Lookup Cache Distribution | ||
id: cache-leveldb | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./leveldb/build/Release/* | ||
key: leveldb-windows-${{ matrix.arch }} | ||
enableCrossOsArchive: true | ||
lookup-only: true | ||
|
||
- if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }} | ||
vncoelho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: Checkout Repository Code (leveldb) | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: google/leveldb | ||
path: leveldb | ||
submodules: true | ||
fetch-depth: 0 | ||
|
||
- if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }} | ||
name: Setup MSBuild | ||
uses: microsoft/setup-msbuild@v2 | ||
|
||
- if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }} | ||
name: Setup LevelDb | ||
working-directory: ./leveldb | ||
run: mkdir -p ./build/Release | ||
|
||
- if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }} | ||
name: Create Build Files (win-${{ matrix.arch }}) | ||
working-directory: ./leveldb/build | ||
run: cmake -DBUILD_SHARED_LIBS=ON -A ${{ matrix.arch }} .. | ||
|
||
- if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }} | ||
name: Build (MSBuild) | ||
working-directory: ./leveldb/build | ||
run: msbuild ./leveldb.sln /p:Configuration=Release | ||
|
||
- if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }} | ||
name: Cache Distribution | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: ./leveldb/build/Release/* | ||
key: leveldb-windows-${{ matrix.arch }} | ||
enableCrossOsArchive: true | ||
|
||
build-neo-cli: | ||
needs: [build-leveldb] | ||
name: Build & Publish TarBalls (${{ matrix.runtime }}) | ||
vncoelho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
runtime: [linux-x64, linux-arm64, win-x64, win-arm64, osx-x64, osx-arm64] | ||
|
||
steps: | ||
- name: Set Application Version (Environment Variable) | ||
run: | | ||
APP_VERSION=$(echo '${{ github.event.release.tag_name }}' | cut -d 'v' -f 2) | ||
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV | ||
|
||
- name: Checkout Repository Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: ${{ env.DOTNET_VERSION }} | ||
|
||
- name: .NET Publish (neo-cli) | ||
run: | | ||
dotnet publish ./src/Neo.CLI \ | ||
--version-suffix ${{ matrix.runtime }} \ | ||
--framework net8.0 \ | ||
--configuration ${{ env.CONFIGURATION }} \ | ||
--runtime ${{ matrix.runtime }} \ | ||
--self-contained true \ | ||
--output ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} \ | ||
--verbosity normal \ | ||
-p:VersionPrefix=${{ env.APP_VERSION }} \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. too much parameters as well.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too much parameter? Like those are not necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that a README or comments are necessary, there are several details There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are all the settings i found to work. |
||
-p:RuntimeIdentifier=${{ matrix.runtime }} \ | ||
-p:SelfContained=true \ | ||
-p:IncludeNativeLibrariesForSelfExtract=false \ | ||
-p:PublishTrimmed=false \ | ||
-p:PublishSingleFile=true \ | ||
-p:PublishReadyToRun=true \ | ||
-p:EnableCompressionInSingleFile=true \ | ||
-p:DebugType=embedded \ | ||
-p:ServerGarbageCollection=true | ||
|
||
- name: .NET Build (LevelDBStore) | ||
run: | | ||
dotnet build ./src/Plugins/LevelDBStore \ | ||
--version-suffix ${{ matrix.runtime }} \ | ||
--framework net8.0 \ | ||
--configuration ${{ env.CONFIGURATION }} \ | ||
--output ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }}/Plugins/LevelDBStore \ | ||
--verbosity normal \ | ||
-p:VersionPrefix=${{ env.APP_VERSION }} | ||
|
||
- name: Remove files (junk) | ||
working-directory: ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }}/Plugins/LevelDBStore | ||
run: | | ||
rm -v Neo* | ||
rm -v *.pdb | ||
rm -v *.xml | ||
|
||
- name: Remove Xml Comment Files | ||
working-directory: ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} | ||
run: rm -v *.xml | ||
|
||
- if: ${{ startsWith(matrix.runtime, 'win-x64') }} | ||
name: Get Distribution Caches (win-x64) | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./leveldb/build/Release/* | ||
key: leveldb-windows-x64 | ||
enableCrossOsArchive: true | ||
fail-on-cache-miss: true | ||
|
||
- if: ${{ startsWith(matrix.runtime, 'win-arm64') }} | ||
name: Get Distribution Caches (win-arm64) | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./leveldb/build/Release/* | ||
key: leveldb-windows-arm64 | ||
enableCrossOsArchive: true | ||
fail-on-cache-miss: true | ||
|
||
- if: ${{ startsWith(matrix.runtime, 'win') }} | ||
name: Copy Files (leveldb) (win) | ||
run: cp -v ./leveldb/build/Release/leveldb.dll ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }}/libleveldb.dll | ||
|
||
- name: Create Distribution Directory | ||
run: mkdir -p ${{ env.DIST_PATH }} | ||
|
||
- name: Create Tarball File (linux) | ||
if: ${{ startsWith(matrix.runtime, 'linux') }} | ||
working-directory: ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} | ||
run: tar -czvf ${{ env.DIST_PATH }}/neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.tar.gz . | ||
|
||
- name: Create Tarball File (osx) | ||
if: ${{ startsWith(matrix.runtime, 'osx') }} | ||
working-directory: ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} | ||
run: tar -cJf ${{ env.DIST_PATH }}/neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.tar.xz . | ||
|
||
- name: Create Zip File (win) | ||
if: ${{ startsWith(matrix.runtime, 'win') }} | ||
working-directory: ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} | ||
run: zip ${{ env.DIST_PATH }}/neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.zip -r * | ||
|
||
- name: Create Checksum Files (linux) | ||
if: ${{ startsWith(matrix.runtime, 'linux') }} | ||
working-directory: ${{ env.DIST_PATH }} | ||
env: | ||
FILENAME: neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }} | ||
run: | | ||
sha256sum ${{ env.FILENAME }}.tar.gz > ${{ env.FILENAME }}.sha256 | ||
|
||
- name: Create Checksum Files (osx) | ||
if: ${{ startsWith(matrix.runtime, 'osx') }} | ||
working-directory: ${{ env.DIST_PATH }} | ||
env: | ||
FILENAME: neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }} | ||
run: | | ||
sha256sum ${{ env.FILENAME }}.tar.xz > ${{ env.FILENAME }}.sha256 | ||
|
||
- name: Create Checksum Files (win) | ||
if: ${{ startsWith(matrix.runtime, 'win') }} | ||
working-directory: ${{ env.DIST_PATH }} | ||
env: | ||
FILENAME: neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }} | ||
run: | | ||
sha256sum ${{ env.FILENAME }}.zip > ${{ env.FILENAME }}.sha256 | ||
|
||
- name: Output/Distribution Directory Contents | ||
run: | | ||
ls -la ${{ env.DIST_PATH }} | ||
ls -la ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }} | ||
|
||
- name: Upload Tarball File (linux) | ||
if: ${{ startsWith(matrix.runtime, 'linux') }} | ||
uses: actions/upload-release-asset@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ${{ env.DIST_PATH }}/neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.tar.gz | ||
asset_name: neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.tar.gz | ||
asset_content_type: application/x-gtar | ||
|
||
- name: Upload Tarball File (osx) | ||
if: ${{ startsWith(matrix.runtime, 'osx') }} | ||
uses: actions/upload-release-asset@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ${{ env.DIST_PATH }}/neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.tar.xz | ||
asset_name: neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.tar.xz | ||
asset_content_type: application/x-gtar | ||
|
||
- name: Upload Zip File (win) | ||
if: ${{ startsWith(matrix.runtime, 'win') }} | ||
uses: actions/upload-release-asset@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ${{ env.DIST_PATH }}/neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.zip | ||
asset_name: neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.zip | ||
asset_content_type: application/zip | ||
|
||
- name: Upload Checksum File (all) | ||
uses: actions/upload-release-asset@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ${{ env.DIST_PATH }}/neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.sha256 | ||
asset_name: neo-cli.v${{ env.APP_VERSION }}-${{ matrix.runtime }}.sha256 | ||
asset_content_type: text/plain | ||
|
||
cleanup: | ||
needs: [build-neo-cli] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cleanup | ||
run: | | ||
gh extension install actions/gh-actions-cache | ||
|
||
echo "Fetching list of cache key" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this can be a script that is called here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cschuchardt88 , move this Cleanup to a script There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what would the extension be for the file? Type of shell to use? Bash? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bourne Again Shell looks good. |
||
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) | ||
|
||
## Setting this to not fail the workflow while deleting cache keys. | ||
set +e | ||
echo "Deleting caches..." | ||
for cacheKey in $cacheKeysForPR | ||
do | ||
if [ "$cacheKey" != "leveldb-windows-x64" ] && [ "$cacheKey" != "leveldb-windows-arm64" ] | ||
then | ||
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm | ||
fi | ||
done | ||
echo "Done" | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
REPO: ${{ github.repository }} | ||
BRANCH: ${{ github.ref }} |
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 how about the manually-triggered builds, don't we need them?
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.
What are you talking about this is automatic on a
publish
release