Skip to content

Commit

Permalink
feat: add ci action to build releases using docker
Browse files Browse the repository at this point in the history
MelchiorKokernoot committed Dec 19, 2024
1 parent 5b7b0b2 commit 74f1c23
Showing 2 changed files with 46 additions and 49 deletions.
93 changes: 45 additions & 48 deletions .github/workflows/release-debian.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release - Debian
name: Release

on:
workflow_dispatch:
@@ -9,69 +9,66 @@ on:
default: "next"

jobs:
tagged-release:
runs-on: ubuntu-latest
container: debian:12
build-release:
runs-on: ubuntu-20.04
env:
MIX_ENV: prod

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Add Debian 11 repository and install OpenSSL 1.1
- name: Set TAG and VERSION
id: vars
run: |
echo "deb http://deb.debian.org/debian bullseye main" | tee -a /etc/apt/sources.list.d/bullseye.list
apt update
apt install -y libssl1.1
rm /etc/apt/sources.list.d/bullseye.list
apt update
TAG="${{ inputs.bundle }}_$(date +%F)_${{ github.run_number }}"
echo "TAG=$TAG" >> $GITHUB_ENV
echo "VERSION=$TAG" >> $GITHUB_ENV
shell: bash

- name: Install Node.js
run: |
apt-get update
apt-get install -y curl git build-essential
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt-get install -y nodejs
- name: Tag name
id: tag
run: echo "TAG=${{ github.event.inputs.bundle }}_$(date +%F)_${{ github.run_number }}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- id: setup-elixir
uses: erlef/setup-elixir@v1
- name: Build Docker Image with cache
uses: docker/build-push-action@v5
with:
otp-version: "25.3.2.7"
elixir-version: "1.14.0"
context: .
file: ./Dockerfile
tags: next-platform:latest
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Setup the Elixir project
- name: Run build inside Docker
run: |
mix deps.get
working-directory: core
docker run --rm \
-e MIX_ENV=$MIX_ENV \
-e BUNDLE=${{ inputs.bundle }} \
-e VERSION=$VERSION \
-v ${{ github.workspace }}:/app \
next-platform:latest \
bash -c "cd /app/core && mix deps.get && ./scripts/build-frontend && ./scripts/build-release"
- name: Build Frontend
run: |
./scripts/build-frontend
- name: Archive release
working-directory: core

- name: Build release
run: |
./scripts/build-release
working-directory: core
env:
BUNDLE: ${{ github.event.inputs.bundle }}
VERSION: ${{ env.TAG }}
tar cfj "${VERSION}.tar.bz2" "${VERSION}"
- name: Archive release
run: |
tar cfj "../${{ env.TAG }}.tar.bz2" "${{ env.TAG }}"
working-directory: core
- name: Verify artifact
run: ls -l core/*.tar.bz2

# - name: Create GitHub Release
# uses: softprops/action-gh-release@v2
# with:
# tag_name: ${{ env.VERSION }}
# prerelease: false
# fail_on_unmatched_files: true
# files: |
# core/${{ env.VERSION }}.tar.bz2

- name: Publish Release
uses: softprops/action-gh-release@v2
- name: Upload release artifact
uses: actions/upload-artifact@v3
with:
tag_name: "${{ env.TAG }}"
prerelease: false
fail_on_unmatched_files: true
files: |
${{ env.TAG }}.tar.bz2
name: release-artifact
path: core/${{ env.VERSION }}.tar.bz2
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.2 \
&& echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc \
&& echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc

RUN echo "export PATH=\"$HOME/.asdf/bin:$HOME/.asdf/shims:$PATH\"" >> ~/.bashrc
ENV PATH="/root/.asdf/bin:/root/.asdf/shims:${PATH}"

RUN bash -c "source ~/.bashrc && \
asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git && \

0 comments on commit 74f1c23

Please sign in to comment.