Skip to content

Remove unnecessary stuff #2

Remove unnecessary stuff

Remove unnecessary stuff #2

name: Release
on:
workflow_dispatch:
push:
branches: [chore/oracle_support]
tags:
- "v*.*.*"
env:
CARGO_TERM_COLOR: always
BUCKET_NAME: "dozer-releases"
ECR_REGISTRY: public.ecr.aws/k7k6x1d4
ECR_REPOSITORY: dozer
DOCKERHUB_REGISTRY: getdozer
DOCKERHUB_REPOSITORY: dozer
permissions:
id-token: write # This is required for requesting the JWT
contents: write # This is required for actions/checkout
jobs:
# https://github.com/orhun/git-cliff/blob/main/.github/workflows/cd.yml
prepare:
name: Prepare
runs-on: ubuntu-20.04
timeout-minutes: 60
outputs:
release_body: ${{ steps.release.outputs.release_body }}
version: ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.prerelease }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'recursive'
- name: Set release version
id: version
run: |
tag=$(printf "%q" ${{ github.ref_name }})
release:
name: Release
runs-on:
labels: ${{ matrix.os }}
needs: prepare
strategy:
matrix:
os: [ubuntu-20.04]
include:
- os: ubuntu-20.04
file_name: dozer
target: x86_64-unknown-linux-gnu
asset_name: dozer-linux-amd64
- os: macos-12
file_name: dozer
target: x86_64-apple-darwin
asset_name: dozer-macos-amd64
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install minimal stable with clippy and rustfmt
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
components: rustfmt, clippy
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Rust cache
uses: swatinem/rust-cache@v2
- name: Install cargo-deb
if: matrix.os == 'ubuntu-20.04'
run: cargo install cargo-deb
- name: Compile deb file
if: matrix.os == 'ubuntu-20.04'
run: cargo-deb -p dozer-cli --output ./deb/${{matrix.asset_name}}.deb
- name: Build package
if: matrix.os != 'ubuntu-20.04'
run: cargo build --release --bin ${{ matrix.file_name }}
- name: Build package for ubuntu (with kafka & snowflake)
if: matrix.os == 'ubuntu-20.04'
run: cargo build --release --bin ${{ matrix.file_name }} --features "kafka snowflake"
- name: Prepare release assets
shell: bash
run: |
mkdir -p release
cp {LICENSE,README.md,CHANGELOG.md} release/ 2> /dev/null || echo "Copy Failed...Ignoring.."
cp target/release/${{matrix.file_name}} release/
mv release/ ${{matrix.asset_name}}/
tar -czvf ${{matrix.asset_name}}.tar.gz \
${{matrix.asset_name}}/
cp deb/${{matrix.asset_name}}.deb ./ 2>/dev/null || :
ls -l ${{matrix.asset_name}}*
- name: Upload the release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{matrix.asset_name}}*
file_glob: true
overwrite: true
tag: ${{ needs.prepare.outputs.version }}
release_name: "Development Release - ${{ needs.prepare.outputs.version }}"
prerelease: ${{ needs.prepare.outputs.prerelease }}
body: "${{ needs.prepare.outputs.release_body }}"
- name: Set env variables
env:
VERSION: ${{ needs.prepare.outputs.version }}
RELEASE_NAME: ${{matrix.asset_name}}.tar.gz
run: |
echo "RELEASE_NAME=${{env.RELEASE_NAME}}" >> $GITHUB_ENV
echo "DEB_NAME=${{matrix.asset_name}}.deb" >> $GITHUB_ENV
echo "VERSION=${{env.VERSION}}" >> $GITHUB_ENV
echo "ARTIFACT_URL=https://${{ env.BUCKET_NAME }}.s3.ap-southeast-1.amazonaws.com/${{ env.VERSION }}/${{ env.RELEASE_NAME }}" >> $GITHUB_ENV
- name: configure aws credentials
if: matrix.os == 'ubuntu-20.04'
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: deployer
aws-region: ap-southeast-1
- name: Upload release to S3
id: upload_s3
if: matrix.os == 'ubuntu-20.04'
run: |
aws s3 cp $RELEASE_NAME s3://${{ env.BUCKET_NAME }}/$VERSION/$RELEASE_NAME
- name: Upload release deb to S3
id: upload_s3_deb
if: matrix.os == 'ubuntu-20.04'
run: |
aws s3 cp deb/$DEB_NAME s3://${{ env.BUCKET_NAME }}/$VERSION/$DEB_NAME
- name: Build, tag, and push image to Amazon ECR
id: build_push_ecr
if: matrix.os == 'ubuntu-20.04'
env:
IMAGE_TAG: ${{ needs.prepare.outputs.version }}
run: |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REGISTRY
docker build -f ci/Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA .
docker push $ECR_REGISTRY/$ECR_REPOSITORY --all-tags