Skip to content
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

ci: add release asset github action #15

Merged
merged 7 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Push Docker Images
# Build & Push builds the finschia docker image on every tag push

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-alpha1

env:
registry: docker.io
DOCKER_REPOSITORY: finschia/finschianode-proxy
RUNNER_BASE_IMAGE_ALPINE: alpine:3.17
jobs:
docker_build_and_push:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create a context for buildx
run: docker context create buildx

- name: Set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Login to the registry
uses: docker/login-action@v2
with:
registry: ${{env.registry}}
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}

- name: Find go version
id: find_go_version
run: |
GO_VERSION=$(cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
zemyblue marked this conversation as resolved.
Show resolved Hide resolved
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV

- name: Find Ostracon version
id: find_ostracon_version
run: |
OST_VERSION=$(go list -m github.com/Finschia/ostracon | sed 's:.* ::')
0Tech marked this conversation as resolved.
Show resolved Hide resolved
echo "OST_VERSION=$OST_VERSION" >> $GITHUB_ENV

- name: Parse tag
id: tag
run: |
ref='refs/tags/'
if [[ ${{ github.ref }} == *${ref}* ]]; then
VERSION=$(echo ${{ github.ref_name }} | sed "s/v//")
echo "VERSION=$VERSION" >> $GITHUB_ENV
else
echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV
fi

- name: Extract metadata for docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{env.registry}}/${{env.DOCKER_REPOSITORY}}
tags: |
type=semver,pattern={{version}}

# Build Docker image
- name: Build and push
uses: docker/build-push-action@v4
with:
file: Dockerfile
context: .
push: true
platforms: linux/amd64,linux/arm64
build-args: |
GO_VERSION=${{ env.GO_VERSION }}
RUNNER_IMAGE=${{ env.RUNNER_BASE_IMAGE_ALPINE }}
GIT_VERSION=${{ env.VERSION }}
GIT_COMMIT=${{ github.sha }}
OST_VERSION=${{ env.OST_VERSION }}
tags: |
${{ env.DOCKER_REPOSITORY }}:${{ env.VERSION }}
labels: ${{steps.meta.outputs.labels}}
28 changes: 14 additions & 14 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ jobs:
uses: actions/checkout@v3.1.0
- name: "Create compressed repository source"
run: |
git archive --format=tar.gz --prefix="fnsad-${{ env.VERSION }}/" HEAD -o fnsad-${{ env.VERSION }}.tar.gz
git archive --format=tar.gz --prefix="fnsad-proxy-${{ env.VERSION }}/" HEAD -o fnsad-proxy-${{ env.VERSION }}.tar.gz
- name: "Store compressed source"
uses: actions/upload-artifact@v3
with:
name: release-${{ env.VERSION }}
path: |
fnsad-${{ env.VERSION }}.tar.gz
fnsad-proxy-${{ env.VERSION }}.tar.gz


build_for_linux_static:
Expand All @@ -49,14 +49,14 @@ jobs:
run: |
make build-reproducible ARCH=${{ matrix.arch }}
cd ./build
mv fnsad-linux-${{ matrix.arch }} fnsad-${{ env.ID }}
mv fnsad-proxy-linux-${{ matrix.arch }} fnsad-proxy-${{ env.ID }}

- name: Store artifact linux-${{ matrix.arch }}
uses: actions/upload-artifact@v3
with:
name: release-${{ env.VERSION }}
path: |
./build/fnsad-${{ env.ID }}
./build/fnsad-proxy-${{ env.ID }}

create_release:
name: Create Release
Expand All @@ -73,21 +73,21 @@ jobs:

- name: Extract compressed repository source
run: |
tar zxvf fnsad-${{ env.VERSION }}.tar.gz --strip-components=1 fnsad-${{ env.VERSION }}/RELEASE_NOTE.md
tar zxvf fnsad-proxy-${{ env.VERSION }}.tar.gz --strip-components=1 fnsad-proxy-${{ env.VERSION }}/RELEASE_NOTE.md

- name: Create build report
run: |
echo "App: finschia" >> build_report.txt
echo "Version: ${{ env.VERSION }}" >> build_report.txt
echo "Commit: ${{ github.sha }}" >> build_report.txt
echo "Checksums MD5:" >> build_report.txt
md5sum fnsad-${{ env.VERSION }}* | sed 's/^/ /' >> build_report.txt
md5sum fnsad-proxy-${{ env.VERSION }}* | sed 's/^/ /' >> build_report.txt
echo "Checksums SHA256:" >> build_report.txt
sha256sum fnsad-${{ env.VERSION }}* | sed 's/^/ /' >> build_report.txt
sha256sum fnsad-proxy-${{ env.VERSION }}* | sed 's/^/ /' >> build_report.txt

- name: Create sha256sum
run: |
sha256sum fnsad-${{ env.VERSION }}* >> sha256sum.txt
sha256sum fnsad-proxy-${{ env.VERSION }}* >> sha256sum.txt

- name: Create release note
run: |
Expand Down Expand Up @@ -125,8 +125,8 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./fnsad-${{ env.VERSION }}-linux-amd64
asset_name: fnsad-${{ env.VERSION }}-linux-amd64
asset_path: ./fnsad-proxy-${{ env.VERSION }}-linux-amd64
asset_name: fnsad-proxy-${{ env.VERSION }}-linux-amd64
asset_content_type: application/binary

- name: Upload linux-arm64 artifact
Expand All @@ -135,8 +135,8 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./fnsad-${{ env.VERSION }}-linux-arm64
asset_name: fnsad-${{ env.VERSION }}-linux-arm64
asset_path: ./fnsad-proxy-${{ env.VERSION }}-linux-arm64
asset_name: fnsad-proxy-${{ env.VERSION }}-linux-arm64
asset_content_type: application/binary

- name: Upload compression
Expand All @@ -145,6 +145,6 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./fnsad-${{ env.VERSION }}.tar.gz
asset_name: fnsad-${{ env.VERSION }}.tar.gz
asset_path: ./fnsad-proxy-${{ env.VERSION }}.tar.gz
asset_name: fnsad-proxy-${{ env.VERSION }}.tar.gz
asset_content_type: application/gzip
Loading