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

Github action release flow #327

Merged
merged 38 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e8c13ed
test environment
lassemand Oct 31, 2024
96e49db
make validation step
lassemand Oct 31, 2024
f7a7415
test stuff
lassemand Oct 31, 2024
5d146d8
test
lassemand Nov 4, 2024
0423928
test
lassemand Nov 4, 2024
da96777
add permissions field
lassemand Nov 4, 2024
6640541
test release flow
lassemand Nov 4, 2024
4af5666
use yq
lassemand Nov 4, 2024
ad5338d
test build
lassemand Nov 4, 2024
d9e1c1c
test version
lassemand Nov 4, 2024
6f786b5
fix runs on
lassemand Nov 4, 2024
a1a3146
ls adn echo
lassemand Nov 4, 2024
fde4bc7
mkdir out
lassemand Nov 4, 2024
ba7c6b3
list files
lassemand Nov 5, 2024
fb32718
add aws credentials
lassemand Nov 5, 2024
79c801b
add environment
lassemand Nov 5, 2024
e3fa6b9
test release flow
lassemand Nov 5, 2024
e2c7435
initialise deps
lassemand Nov 5, 2024
9b8c9b4
echo content
lassemand Nov 5, 2024
5557907
ensure to install jq
lassemand Nov 6, 2024
2031434
do not run macos
lassemand Nov 6, 2024
d2ab1fb
list folders
lassemand Nov 7, 2024
d817062
get location of strip
lassemand Nov 7, 2024
d195313
test windows release flow
lassemand Nov 7, 2024
79dcefe
fix directory creation
lassemand Nov 7, 2024
b906169
bump patch
lassemand Nov 8, 2024
a024805
bump version
lassemand Nov 8, 2024
6d75be2
made a client release
lassemand Nov 8, 2024
1a09f62
refer to correct version
lassemand Nov 8, 2024
8625f91
bump version
lassemand Nov 8, 2024
85af55e
fix version
lassemand Nov 8, 2024
f52eeff
pwd test
lassemand Nov 13, 2024
7719646
bump build
lassemand Nov 13, 2024
2d5e750
fix pathing
lassemand Nov 13, 2024
533ab0a
remove branch release
lassemand Nov 13, 2024
b4fd34e
remove which
lassemand Nov 25, 2024
19d674b
merged with main
lassemand Nov 25, 2024
8b1af85
remove docker tags
lassemand Nov 25, 2024
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
269 changes: 269 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
name: Concordium client release

on:
workflow_dispatch:
inputs:
service:
type: choice
description: Choose which workflow should be ran
options:
- client-macos
- client-windows
- client-linux

push:
tags:
- '*.*.*-*-rc'

env:
S3_ARN_TEMPLATES: '{
\"client-linux\": \"s3://distribution.concordium.software/tools/linux/concordium-client_${VERSION}\",
\"client-macos\": \"s3://distribution.concordium.software/tools/macos/concordium-client_${VERSION}-unsigned.pkg\",
\"client-windows\": \"s3://distribution.concordium.software/tools/windows/concordium-client_${VERSION}.zip\"
}'
AWS_ROLE_TO_ASSUME: 'arn:aws:iam::192549843005:role/github_concordium-client'
STACK_VERSION: '2.13.1'
GHC_VERSION: '9.6.4'
RUST_VERSION: '1.73'
CABAL_VERSION: '3.6.2.0'
SERVICE: "${{ inputs.service }}"
PROTOC_VERSION: '25.2'
FLATBUFFERS_VERSION: '23.5.26'

permissions:
id-token: write
contents: read

jobs:
validate-preconditions:
runs-on: ubuntu-latest
environment: release
outputs:
s3_arns: ${{ steps.render.outputs.s3_arns }}
release_type: ${{ steps.versions_derivation.outputs.release_type }}
base_version: ${{ steps.versions_derivation.outputs.base_version }}
version: ${{ steps.versions_derivation.outputs.version }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }}
role-session-name: ClientPreconditionsSession
aws-region: "eu-west-1"

- name: Validate version
id: versions_derivation
run: |
CARGO_VERSION=$(yq .version package.yaml)
if [ -z "${{ env.SERVICE }}" ]; then
IFS='-' read -r VERSION BUILD RELEASE_TYPE <<< "${{ github.ref_name }}"
if [ ! "$VERSION" = "$CARGO_VERSION" ]; then
echo "::error::${CARGO_VERSION} does not match ${VERSION}."
exit 1
fi
else
RELEASE_TYPE="${{ env.SERVICE }}"
BUILD=$(git rev-parse --short HEAD)
fi
echo "::notice::RELEASE_TYPE=${RELEASE_TYPE}"
echo "release_type=${RELEASE_TYPE}" >> "$GITHUB_OUTPUT"
echo "version=${CARGO_VERSION}-${BUILD}" >> "$GITHUB_OUTPUT"
echo "base_version=${CARGO_VERSION}" >> "$GITHUB_OUTPUT"

- name: Templates rendering
id: render
run: |
export VERSION="${{ steps.versions_derivation.outputs.version }}"
echo "s3_arns=${{ env.S3_ARN_TEMPLATES }}" >> $GITHUB_OUTPUT

- name: Validate whether s3 artifacts are not existing
if: contains(fromJSON('["rc"]'), steps.versions_derivation.outputs.release_type)
run: |
set +e
echo '${{ steps.render.outputs.s3_arns }}' | jq -r '. | to_entries[] | .value' | while read -r ARN; do
echo "Checking for object at: $ARN"
S3_OUTPUT=$(aws s3 ls "$ARN" --summarize 2>&1)
EXIT_CODE=$?
if [ $EXIT_CODE -eq 1 ]; then
echo "No object found for $ARN, proceeding."
elif [ $EXIT_CODE -eq 0 ]; then
echo "::error::item for $ARN already exists."
exit 1
else
echo "::error::Unexpected exit code: $EXIT_CODE for $ARN."
exit 1
fi
done

client-linux:
needs: [validate-preconditions]
runs-on: ubuntu-latest
environment: release
if: contains(fromJSON('["rc", "client-linux"]'), needs.validate-preconditions.outputs.release_type)
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ github.job }}Session
aws-region: "eu-west-1"

- name: Build Concordium Client Image
uses: docker/build-push-action@v6
with:
context: .
push: false
file: scripts/distributables/linux-distributable-concordium-client.Dockerfile
tags: ${{ github.job }}:${{ github.run_id }}
no-cache: true
build-args: |
GHC_VERSION=${{ env.GHC_VERSION }}
RUST_VERSION=${{ env.RUST_VERSION }}
STACK_VERSION=${{ env.STACK_VERSION }}
labels: |
stack_version=${{ env.STACK_VERSION }}
rust_version=${{ env.RUST_VERSION }}
ghc_version=${{ env.GHC_VERSION }}
- name: Create container and Extract Artifact
run: |
id=$(docker create ${{ github.job }}:${{ github.run_id }})
docker cp $id:/out/concordium-client .
- name: Publish
run: |
OUTFILE=$(echo '${{ needs.validate-preconditions.outputs.s3_arns }}' | jq -r '.["${{ github.job }}"]')
aws s3 cp "concordium-client" \
"$OUTFILE" --grants=read=uri=http://acs.amazonaws.com/groups/global/AllUsers

client-macos:
needs: [validate-preconditions]
runs-on: macos-latest-large
environment: release
if: contains(fromJSON('["rc", "client-macos"]'), needs.validate-preconditions.outputs.release_type)
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive


- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ github.job }}Session
aws-region: "eu-west-1"

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}

- uses: haskell-actions/setup@v2
with:
ghc-version: ${{ env.GHC_VERSION }}
cabal-version: ${{ env.CABAL_VERSION }}
enable-stack: true
stack-version: ${{ env.STACK_VERSION }}

- name: Install flatbuffers
run: |
wget https://github.com/google/flatbuffers/releases/download/v${{ env.FLATBUFFERS_VERSION }}/MacIntel.flatc.binary.zip -O MacIntel.flatc.binary.zip
unzip MacIntel.flatc.binary.zip -d flatbuffers
sudo mv flatbuffers/flatc /usr/local/bin/

- name: Install protobuf
run: |
curl -L -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v${{ env.PROTOC_VERSION }}/protoc-${{ env.PROTOC_VERSION }}-osx-x86_64.zip
unzip protoc.zip
sudo mv bin/protoc /usr/local/bin/
sudo mv include/* /usr/local/include/

- name: Build
run: |
scripts/distributables/macOS-package/build.sh --build "${{ needs.validate-preconditions.outputs.version }}"

- name: Publish
run: |
OUTFILE=$(echo '${{ needs.validate-preconditions.outputs.s3_arns }}' | jq -r '.["${{ github.job }}"]')
aws s3 cp "./scripts/distributables/macOS-package/build/concordium-client-${{ needs.validate-preconditions.outputs.version }}-unsigned.pkg" \
"$OUTFILE" --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers


client-windows:
needs: [validate-preconditions]
runs-on: windows-latest
environment: release
if: contains(fromJSON('["rc", "client-windows"]'), needs.validate-preconditions.outputs.release_type)
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
choco install yq jq -y
shell: bash

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ github.job }}Session
aws-region: "eu-west-1"

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}-x86_64-pc-windows-gnu

- uses: haskell-actions/setup@v2
with:
ghc-version: ${{ env.GHC_VERSION }}
cabal-version: ${{ env.CABAL_VERSION }}
enable-stack: true
stack-version: ${{ env.STACK_VERSION }}

- name: Setup client folder
run: |
mkdir -p "C:/Program Files/client/include"
Add-Content -Path $env:GITHUB_PATH -Value "C:/Program Files/client"

- name: Install flatbuffers
run: |
curl -L -O https://github.com/google/flatbuffers/releases/download/v${{ env.FLATBUFFERS_VERSION }}/Windows.flatc.binary.zip
unzip Windows.flatc.binary.zip
mv flatc.exe "C:/Program Files/client/"

- name: Install protobuf (protoc)
run: |
curl -L -O https://github.com/protocolbuffers/protobuf/releases/download/v${{ env.PROTOC_VERSION }}/protoc-${{ env.PROTOC_VERSION }}-win64.zip
unzip protoc-${{ env.PROTOC_VERSION }}-win64.zip
mv bin/protoc.exe "C:/Program Files/client/"
mv include/* "C:/Program Files/client/include"

- name: Build
run: stack build --force-dirty

- name: Zip the binaries
shell: bash
run: |
mkdir -p out
bin_dir=$(stack path --local-install-root)/bin
echo "$bin_dir"
(cd "$bin_dir" && powershell -Command "Compress-Archive -Path concordium-client.exe,concordium_base.dll,sha_2.dll -DestinationPath concordium-client.zip")
mv -f "$bin_dir/concordium-client.zip" out/concordium-client.zip

- name: Publish
shell: bash
run: |
OUTFILE=$(echo '${{ needs.validate-preconditions.outputs.s3_arns }}' | jq -r '.["${{ github.job }}"]')
aws s3 cp out/concordium-client.zip \
"$OUTFILE" --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers

2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: concordium-client
version: 7.0.1
version: 7.0.2
lassemand marked this conversation as resolved.
Show resolved Hide resolved
github: "Concordium/concordium-client"
author: "Concordium"
maintainer: "[email protected]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ sed -i "s/default: False/default: True/g" deps/concordium-base/concordium-base.c
stack build --stack-yaml stack.linux-static.yaml

LOCAL_INSTALL_ROOT=$(stack --stack-yaml stack.linux-static.yaml path --local-install-root)
mkdir -p /out
cp "$LOCAL_INSTALL_ROOT"/bin/concordium-client /out/concordium-client
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# syntax=docker/dockerfile:experimental

# It seems that linker errors occur on alpine:3.19, which seem to be related to
# (rust) libc and musl, though it is not clear exactly why.
FROM alpine:3.18
Expand All @@ -10,10 +8,10 @@ COPY . /build

RUN apk add perl g++ make protoc ncurses ncurses-dev zlib zlib-static zlib-dev git wget postgresql-dev gmp-dev gmp xz

ARG RUST_VERSION=1.82
ARG RUST_VERSION
RUN wget -qO - https://sh.rustup.rs | sh -s -- --profile minimal --default-toolchain ${RUST_VERSION} -y

ARG GHC_VERSION=9.6.6
ARG GHC_VERSION
RUN wget -q https://s3-eu-west-1.amazonaws.com/static-libraries.concordium.com/ghc-${GHC_VERSION}-x86_64-unknown-linux-integer-gmp.tar.xz && \
tar -xf ghc-${GHC_VERSION}-x86_64-unknown-linux-integer-gmp.tar.xz && \
cd ghc-${GHC_VERSION}-x86_64-unknown-linux && \
Expand All @@ -22,7 +20,7 @@ RUN wget -q https://s3-eu-west-1.amazonaws.com/static-libraries.concordium.com/g
cd .. && \
rm -rf ghc-${GHC_VERSION}-x86_64-unknown-linux-integer-gmp.tar.xz ghc-${GHC_VERSION}-x86_64-unknown-linux

ARG STACK_VERSION=2.13.1
ARG STACK_VERSION
RUN wget -q https://github.com/commercialhaskell/stack/releases/download/v${STACK_VERSION}/stack-${STACK_VERSION}-linux-x86_64.tar.gz && \
tar -xf stack-${STACK_VERSION}-linux-x86_64.tar.gz && \
mkdir -p $HOME/.stack/bin && \
Expand All @@ -35,4 +33,4 @@ COPY scripts/distributables/linux-build-distributable-concordium-client.sh /buil

RUN chmod +x /build-distributable-concordium-client.sh
WORKDIR /
ENTRYPOINT ["./build-distributable-concordium-client.sh"]
RUN ["./build-distributable-concordium-client.sh"]
Loading