Skip to content

Commit

Permalink
Fix date and commit difference in built packages
Browse files Browse the repository at this point in the history
  • Loading branch information
donhardman committed Oct 20, 2023
1 parent d5df8f7 commit 7f40363
Showing 1 changed file with 45 additions and 35 deletions.
80 changes: 45 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,32 @@ env:
COLUMNAR_VERSION: '2.2.1'

jobs:
vars:
runs-on: ubuntu-22.04
outputs:
app_version: ${{ steps.vars.outputs.app_version }}
app_date: ${{ steps.vars.outputs.app_date }}
app_commit: ${{ steps.vars.outputs.app_commit }}
rpm_suffix: ${{ steps.vars.outputs.rpm_suffix }}
deb_suffix: ${{ steps.vars.outputs.deb_suffix }}

steps:
- uses: actions/checkout@v3
- id: vars
run: |
date=$( date +%y%m%d%H )
commit=${GITHUB_SHA:0:7}
echo "app_version=$(echo ${{ github.ref_name }} | cut -dv -f2)" >> $GITHUB_OUTPUT
echo "app_date=$date" >> $GITHUB_OUTPUT
echo "app_commit=$commit" >> $GITHUB_OUTPUT
echo "rpm_suffix=_${date}.$commit" >> $GITHUB_OUTPUT
echo "deb_suffix=-${date}-$commit" >> $GITHUB_OUTPUT
build-artifact:
runs-on: ${{ matrix.os }}
needs:
- vars
strategy:
matrix:
include:
Expand All @@ -37,11 +61,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- id: vars
run: |
echo "app_version=$(echo ${{ github.ref_name }} | cut -dv -f2)" >> $GITHUB_OUTPUT
echo "rpm_suffix=_$( date +%y%m%d%H ).${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
echo "deb_suffix=-$( date +%y%m%d%H )-${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
- name: Set up QEMU
if: ${{ matrix.use_buildx == true }}
uses: docker/setup-qemu-action@v2
Expand All @@ -56,16 +75,16 @@ jobs:
platforms: linux/${{ matrix.arch }}
load: true
push: false
tags: ${{ env.DOCKER_TAG }}:${{ steps.vars.outputs.app_version }}
tags: ${{ env.DOCKER_TAG }}:${{ needs.vars.outputs.app_version }}
build-args: BUILD_DEV=0
- name: Create artifact
run: |
[ -n "${{ matrix.run }}" ] && ${{ matrix.run }} ${{ env.PHP_VERSION }} || true
APP_ARCH=${{ matrix.arch }} \
APP_VERSION=${{ steps.vars.outputs.app_version }} \
APP_VERSION=${{ needs.vars.outputs.app_version }} \
APP_NAME=${{ env.APP_NAME }} \
RUNNER_OS="${{ runner.os }}" \
DOCKER_IMAGE=${{ env.DOCKER_TAG }}:${{ steps.vars.outputs.app_version }} \
DOCKER_IMAGE=${{ env.DOCKER_TAG }}:${{ needs.vars.outputs.app_version }} \
./collect-assets
shell: bash
- uses: manticoresoftware/upload_artifact_with_retries@main
Expand All @@ -75,6 +94,8 @@ jobs:

build-artifact-dev:
runs-on: ubuntu-22.04
needs:
- vars
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -87,7 +108,7 @@ jobs:
- name: Create artifact
run: |
APP_ARCH=amd64 \
APP_VERSION=${{ steps.vars.outputs.app_version }} \
APP_VERSION=${{ needs.vars.outputs.app_version }} \
APP_NAME=${{ env.APP_NAME }} \
RUNNER_OS="${{ runner.os }}" \
ASSET_SUFFIX=-dev \
Expand All @@ -100,15 +121,11 @@ jobs:

build-linux-packages:
needs:
- vars
- build-artifact
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- id: vars
run: |
echo "app_version=$(echo ${{ github.ref_name }} | cut -dv -f2)" >> $GITHUB_OUTPUT
echo "rpm_suffix=_$( date +%y%m%d%H ).${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
echo "deb_suffix=-$( date +%y%m%d%H )-${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
- name: Download artifact
uses: manticoresoftware/download_artifact_with_retries@main
with:
Expand Down Expand Up @@ -138,7 +155,7 @@ jobs:
package: ${{ env.APP_NAME }}
package_root: .debpkg
maintainer: ${{ env.MAINTAINER }}
version: ${{ steps.vars.outputs.app_version }}${{ steps.vars.outputs.deb_suffix }}
version: ${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.deb_suffix }}
arch: 'amd64'
desc: '${{ env.DESC }}'
license: 'PHP-3.01'
Expand All @@ -161,7 +178,7 @@ jobs:
# Prepare spec file for RPM
sed -i 's/{{ NAME }}/${{ env.APP_NAME }}/g' $spec_file
sed -i 's/{{ VERSION }}/${{ steps.vars.outputs.app_version }}${{ steps.vars.outputs.rpm_suffix }}/g' $spec_file
sed -i 's/{{ VERSION }}/${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }}/g' $spec_file
sed -i 's/{{ MAINTAINER }}/${{ env.MAINTAINER }}/g' $spec_file
sed -i 's/{{ DESC }}/${{ env.DESC }}/g' $spec_file
sed -i 's/{{ ARCH }}/x86_64/g' $spec_file
Expand All @@ -177,7 +194,7 @@ jobs:
cp -p "$RPMBUILD_DIR/RPMS/x86_64"/*.rpm $GITHUB_WORKSPACE
- name: Rename packages to proper name
run: |
version=${{ steps.vars.outputs.app_version }}${{ steps.vars.outputs.rpm_suffix }}
version=${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }}
rpm_path="./${{ env.APP_NAME }}-${version}-1.x86_64.rpm"
cp $rpm_path "./${{ env.APP_NAME }}-${version}-1.el7.x86_64.rpm"
cp $rpm_path "./${{ env.APP_NAME }}-${version}-1.el8.x86_64.rpm"
Expand Down Expand Up @@ -209,15 +226,11 @@ jobs:
path: ./artifacts/*.el9.*.rpm
build-linux-packages-arm64:
needs:
- vars
- build-artifact
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- id: vars
run: |
echo "app_version=$(echo ${{ github.ref_name }} | cut -dv -f2)" >> $GITHUB_OUTPUT
echo "rpm_suffix=_$( date +%y%m%d%H ).${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
echo "deb_suffix=-$( date +%y%m%d%H )-${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
- name: Download artifact
uses: manticoresoftware/download_artifact_with_retries@main
with:
Expand Down Expand Up @@ -245,7 +258,7 @@ jobs:
package: ${{ env.APP_NAME }}
package_root: .debpkg
maintainer: ${{ env.MAINTAINER }}
version: ${{ steps.vars.outputs.app_version }}${{ steps.vars.outputs.deb_suffix }}
version: ${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.deb_suffix }}
arch: 'arm64'
desc: '${{ env.DESC }}'
license: 'PHP-3.01'
Expand Down Expand Up @@ -287,7 +300,7 @@ jobs:
# Prepare spec file for RPM
sed -i 's/{{ NAME }}/${{ env.APP_NAME }}/g' $spec_file
sed -i 's/{{ VERSION }}/${{ steps.vars.outputs.app_version }}${{ steps.vars.outputs.rpm_suffix }}/g' $spec_file
sed -i 's/{{ VERSION }}/${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }}/g' $spec_file
sed -i 's/{{ MAINTAINER }}/${{ env.MAINTAINER }}/g' $spec_file
sed -i 's/{{ DESC }}/${{ env.DESC }}/g' $spec_file
sed -i 's/{{ ARCH }}/aarch64/g' $spec_file
Expand All @@ -305,7 +318,7 @@ jobs:
- name: Rename package to proper name
run: |
ls -lah ./artifacts/*.rpm
version=${{ steps.vars.outputs.app_version }}${{ steps.vars.outputs.rpm_suffix }}
version=${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }}
rpm_path="./artifacts/${{ env.APP_NAME }}-${version}-1.el7.aarch64.rpm"
cp $rpm_path "./artifacts/${{ env.APP_NAME }}-${version}-1.el8.aarch64.rpm"
cp $rpm_path "./artifacts/${{ env.APP_NAME }}-${version}-1.el9.aarch64.rpm"
Expand All @@ -327,13 +340,10 @@ jobs:

build-extra-packages:
runs-on: ubuntu-22.04
needs:
- vars
steps:
- uses: actions/checkout@v3
- id: vars
run: |
echo "app_version=$(echo ${{ github.ref_name }} | cut -dv -f2)" >> $GITHUB_OUTPUT
echo "rpm_suffix=_$( date +%y%m%d%H ).${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
echo "deb_suffix=-$( date +%y%m%d%H )-${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
- name: Prepare packages structure
run: |
mkdir -p .debpkg/usr/bin
Expand All @@ -346,11 +356,11 @@ jobs:
package: ${{ env.EXTRA_NAME }}
package_root: .debpkg
maintainer: ${{ env.MAINTAINER }}
version: ${{ steps.vars.outputs.app_version }}${{ steps.vars.outputs.deb_suffix }}
version: ${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.deb_suffix }}
arch: 'all'
desc: '${{ env.EXTRA_DESC }}'
license: 'Apache-2.0'
depends: '${{ env.APP_NAME }} (>= ${{ steps.vars.outputs.app_version }}), ${{ env.COLUMNAR_NAME }} (>= ${{ env. COLUMNAR_VERSION }}), ca-certificates'
depends: '${{ env.APP_NAME }} (>= ${{ needs.vars.outputs.app_version }}), ${{ env.COLUMNAR_NAME }} (>= ${{ env. COLUMNAR_VERSION }}), ca-certificates'
- name: Build RPM packages
run: |
sudo apt-get update -y -q
Expand All @@ -369,11 +379,11 @@ jobs:
# Prepare spec file for RPM
sed -i 's/{{ NAME }}/${{ env.EXTRA_NAME }}/g' $spec_file
sed -i 's/{{ VERSION }}/${{ steps.vars.outputs.app_version }}${{ steps.vars.outputs.rpm_suffix }}/g' $spec_file
sed -i 's/{{ VERSION }}/${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }}/g' $spec_file
sed -i 's/{{ MAINTAINER }}/${{ env.MAINTAINER }}/g' $spec_file
sed -i 's/{{ DESC }}/${{ env.EXTRA_DESC }}/g' $spec_file
sed -i 's/{{ EXECUTOR_NAME }}/${{ env.APP_NAME }}/g' $spec_file
sed -i 's/{{ EXECUTOR_VERSION }}/${{ steps.vars.outputs.app_version }}${{ steps.vars.outputs.rpm_suffix }}/g' $spec_file
sed -i 's/{{ EXECUTOR_VERSION }}/${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }}/g' $spec_file
sed -i 's/{{ COLUMNAR_NAME }}/${{ env.COLUMNAR_NAME }}/g' $spec_file
sed -i 's/{{ COLUMNAR_VERSION }}/${{ env.COLUMNAR_VERSION }}/g' $spec_file
Expand All @@ -388,7 +398,7 @@ jobs:
- name: Rename packages to proper name
run: |
version=${{ steps.vars.outputs.app_version }}${{ steps.vars.outputs.rpm_suffix }}
version=${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }}
rpm_path="./${{ env.EXTRA_NAME }}-${version}-1.noarch.rpm"
cp $rpm_path "./${{ env.EXTRA_NAME }}-${version}-1.el7.noarch.rpm"
cp $rpm_path "./${{ env.EXTRA_NAME }}-${version}-1.el8.noarch.rpm"
Expand Down

0 comments on commit 7f40363

Please sign in to comment.