-
Notifications
You must be signed in to change notification settings - Fork 22
70 lines (60 loc) · 3.08 KB
/
Copy pathexecutable-bundle-linux.yml
File metadata and controls
70 lines (60 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: executable-bundle-linux
on:
release:
types: [ published ]
workflow_dispatch:
permissions:
contents: write
jobs:
build-linux:
name: Build Linux Executable Bundle
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies and Build Bundle (Linux)
id: get_bundle_name
run: |
# Ensure repository owner is lowercase for Docker tag
REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
IMAGE_TAG="ghcr.io/${REPO_OWNER}/config-assessment-tool-build:latest"
# Build on a RHEL 8-compatible base so the bundle works on both
# RHEL 8.x and RHEL 9.x hosts (and Ubuntu 20+).
# Use NO_CACHE=true to avoid buildkit caching issues
make build-image DOCKERFILE=backend/Dockerfile-rhel DOCKER_IMAGE_TAG=${IMAGE_TAG} NO_CACHE=true
echo "finished building docker image with Linux bundle included"
# Copy bundle out of built image
# The `find` command is more robust for dynamically named files
tarball_path=$(docker run --rm ${IMAGE_TAG} find /root/config-assessment-tool/dist/ -name "*.tgz")
echo "copying bundle out of image using $tarball_path"
docker cp $(docker create --name temp_image ${IMAGE_TAG}):$tarball_path ./ && docker rm temp_image
echo "finished copying bundle onto hosted runner at $(pwd)"
echo "files in current directory $(ls -altr)"
ORIGINAL_BUNDLE_NAME=$(ls -1 *.tgz | head -n 1)
VERSION="${{ github.ref_name }}"
if [[ -z "$VERSION" ]]; then
VERSION="$(cat VERSION)"
fi
NEW_BUNDLE_NAME="config-assessment-tool-linux-${VERSION}-x86_64-executable.tgz"
mv "$ORIGINAL_BUNDLE_NAME" "$NEW_BUNDLE_NAME"
echo "Renamed $ORIGINAL_BUNDLE_NAME to $NEW_BUNDLE_NAME"
BUNDLE_NAME="$NEW_BUNDLE_NAME"
echo "BUNDLE_NAME=$BUNDLE_NAME" >> $GITHUB_ENV # Set as an environment variable
echo "bundle_name=$BUNDLE_NAME" >> $GITHUB_OUTPUT # Set as step output for clarity
- name: Release the bundle for Linux
if: startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PRERELEASE_FLAG=""
if [[ "${{ github.ref_name }}" == *"-"* ]]; then
PRERELEASE_FLAG="--prerelease"
fi
gh release create ${{ github.ref_name }} ${{ env.BUNDLE_NAME }} --generate-notes --title "${{ github.ref_name }}" $PRERELEASE_FLAG || gh release upload ${{ github.ref_name }} ${{ env.BUNDLE_NAME }} --clobber
- name: Keep workflow artifact within the current workflow namespace (Linux)
uses: actions/upload-artifact@v4
with:
name: ${{ env.BUNDLE_NAME }} # Use the exact bundle name for the artifact
path: ./${{ env.BUNDLE_NAME }} # Specify the full path to the bundle
compression-level: 0 # The .tgz is already compressed, no need to compress again
if-no-files-found: ignore