🎉 fix release ci (#23)

This commit is contained in:
no-reply 2022-05-11 17:13:56 +08:00 committed by GitHub
parent 793530de6f
commit b48059b86c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 80 additions and 36 deletions

71
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,71 @@
name: "Build new artifacts"
on:
pull_request:
branches:
- 'debank'
workflow_dispatch:
env:
BUILT_BINARY_PATH: build/bin
BUILT_BINARY_NAME: geth
ARCHIVE_FILE_NAME: eth-latest-linux-amd64
ARCHIVE_BUCKET: debank-build-artifacts
ARCHIVE_FILE_PREFIX: downloads/ethereum
AWS_REGION: ap-northeast-1
jobs:
build-artifacts:
runs-on: [self-hosted, general]
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.RELEASE_MANAGER_APP_ID }}
private_key: ${{ secrets.RELEASE_MANAGER_APP_SECRET }}
- name: Make binaries
run: |
git config --global url."https://${{ steps.generate-token.outputs.token }}:x-oauth-basic@github.com/DeBankDeFi".insteadOf "https://github.com/DeBankDeFi"
make
- name: Set env
run: |
echo "ARCHIVE_FILE_NAME=eth-$(git rev-parse --short HEAD)-linux-amd64" >> $GITHUB_ENV
- name: Archive artifacts
run: |
mkdir $ARCHIVE_FILE_NAME
cp $BUILT_BINARY_PATH/$BUILT_BINARY_NAME $ARCHIVE_FILE_NAME/$BUILT_BINARY_NAME
sha256sum $ARCHIVE_FILE_NAME/$BUILT_BINARY_NAME --tag >> $ARCHIVE_FILE_NAME/sha256.checksum
chmod u+x $ARCHIVE_FILE_NAME/$BUILT_BINARY_NAME
$ARCHIVE_FILE_NAME/$BUILT_BINARY_NAME version
tar cvfz $ARCHIVE_FILE_NAME.tar.gz $ARCHIVE_FILE_NAME
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
- name: Copy artifacts to s3
run: |
aws s3 cp $ARCHIVE_FILE_NAME.tar.gz s3://$ARCHIVE_BUCKET/$ARCHIVE_FILE_PREFIX/$ARCHIVE_FILE_NAME.tar.gz --acl public-read
- name: comment PR
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: "Artifacts uploaded, click or copy [this link](https://${{ env.ARCHIVE_BUCKET }}.s3.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ARCHIVE_FILE_PREFIX }}/${{ env.ARCHIVE_FILE_NAME }}.tar.gz) to download. :tada:"
check_for_duplicate_msg: true
continue-on-error: true

View file

@ -1,25 +1,20 @@
name: "Release new artifacts"
on:
push:
branches:
- 'debank'
pull_request:
branches:
- 'debank'
release:
types:
- created
workflow_dispatch:
env:
TEMP_ARTIFACT_NAME: geth
BUILT_BINARY_PATH: build/bin
BUILT_BINARY_NAME: geth
ARCHIVE_FILE_NAME: eth-latest-linux-amd64
ARCHIVE_BUCKET: debank-build-artifacts
ARCHIVE_FILE_PREFIX: downloads
ARCHIVE_FILE_PREFIX: downloads/ethereum
AWS_REGION: ap-northeast-1
jobs:
build:
release-artifacts:
runs-on: [self-hosted, general]
steps:
- name: Install Go
@ -43,22 +38,9 @@ jobs:
git config --global url."https://${{ steps.generate-token.outputs.token }}:x-oauth-basic@github.com/DeBankDeFi".insteadOf "https://github.com/DeBankDeFi"
make
- name: Archive built binaries
uses: actions/upload-artifact@v2
with:
name: ${{ env.TEMP_ARTIFACT_NAME }}
path: ${{ env.BUILT_BINARY_PATH }}/${{ env.BUILT_BINARY_NAME }}
retention-days: 1
package:
runs-on: [self-hosted, general]
needs: build
steps:
- name: Download built binaries
uses: actions/download-artifact@v2
with:
name: ${{ env.TEMP_ARTIFACT_NAME }}
path: ${{ env.BUILT_BINARY_PATH }}
- name: Set env
run: |
echo "ARCHIVE_FILE_NAME=eth-${GITHUB_REF#refs/*/}-linux-amd64" >> $GITHUB_ENV
- name: Archive artifacts
run: |
@ -76,13 +58,4 @@ jobs:
- name: Copy artifacts to s3
run: |
aws s3 cp $ARCHIVE_FILE_NAME.tar.gz s3://$ARCHIVE_BUCKET/$ARCHIVE_FILE_PREFIX/$ARCHIVE_FILE_NAME.tar.gz --acl public-read
- name: comment PR
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: "Artifacts uploaded, click or copy [this link](https://${{ env.ARCHIVE_BUCKET }}.s3.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ARCHIVE_FILE_PREFIX }}/${{ env.ARCHIVE_FILE_NAME }}.tar.gz) to download. :tada:"
check_for_duplicate_msg: true
continue-on-error: true
aws s3 cp $ARCHIVE_FILE_NAME.tar.gz s3://$ARCHIVE_BUCKET/$ARCHIVE_FILE_PREFIX/$ARCHIVE_FILE_NAME.tar.gz --acl public-read