Skip to content

Build and Publish RPM Package #166

Build and Publish RPM Package

Build and Publish RPM Package #166

Workflow file for this run

name: Build and Publish Package
on:
create
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_number || github.ref }}
cancel-in-progress: true
jobs:
publish_apisix:
name: Build and Publish RPM Package
runs-on: ubuntu-18.04
timeout-minutes: 60
env:
VAR_COS_BUCKET_CI: ${{ secrets.VAR_COS_BUCKET_CI }}
VAR_COS_BUCKET_REPO: ${{ secrets.VAR_COS_BUCKET_REPO }}
VAR_COS_ENDPOINT: ${{ secrets.VAR_COS_ENDPOINT }}
VAR_RPM_WORKBENCH_DIR: /tmp/output
steps:
- name: Check out code
uses: actions/checkout@v2.3.5
with:
submodules: recursive
- name: Init basic publish env
run: |
# install publish env deps
sudo apt-get update
sudo apt install -y createrepo
mkdir -p "${VAR_RPM_WORKBENCH_DIR}"
# init env var
TAG_DATE=$(date +%Y%m%d)
echo "TAG_DATE=${TAG_DATE}" >> "$GITHUB_ENV"
- name: Extract Tags name
if: ${{ startsWith(github.ref, 'refs/tags/') }}
id: tag_env
shell: bash
run: |
echo "##[set-output name=version;]$(echo ${GITHUB_REF##*/})"
- name: Extract Tags Type
if: ${{ startsWith(github.ref, 'refs/tags/') }}
id: tag_type
shell: bash
run: |
echo "##[set-output name=version;]$(echo ${GITHUB_REF#refs/tags/})"
- name: Build apisix RPM Package
if: ${{ startsWith(steps.tag_type.outputs.version, 'apisix/') }}
env:
APISIX_TAG_VERSION: ${{ steps.tag_env.outputs.version}}
run: |
# build apisix
make package type=rpm app=apisix openresty=apisix-base checkout=${APISIX_TAG_VERSION} version=${APISIX_TAG_VERSION} image_base=centos image_tag=7
make package type=rpm app=apisix openresty=apisix-base checkout=${APISIX_TAG_VERSION} version=${APISIX_TAG_VERSION} image_base=centos image_tag=8
mv ./output/apisix-${APISIX_TAG_VERSION}-0.el{7,8}.x86_64.rpm ${VAR_RPM_WORKBENCH_DIR}
echo "TARGET_APP=apisix" >> "$GITHUB_ENV"
- name: Build apisix-base RPM Package
if: ${{ startsWith(steps.tag_type.outputs.version, 'apisix-base/') }}
env:
APISIX_BASE_TAG_VERSION: ${{ steps.tag_env.outputs.version}}
run: |
# build apisix-base
echo ${{ steps.tag_env.outputs.version}}
echo ${{ steps.tag_type.outputs.version}}
make package type=rpm app=apisix-base checkout=${APISIX_BASE_TAG_VERSION} version=${APISIX_BASE_TAG_VERSION} image_base=centos image_tag=7
make package type=rpm app=apisix-base checkout=${APISIX_BASE_TAG_VERSION} version=${APISIX_BASE_TAG_VERSION} image_base=centos image_tag=8
mv ./output/apisix-base-${APISIX_BASE_TAG_VERSION}-0.el{7,8}.x86_64.rpm ${VAR_RPM_WORKBENCH_DIR}
echo "TARGET_APP=apisix-base" >> "$GITHUB_ENV"
- name: Build apisix-dashboard RPM Package
if: ${{ startsWith(steps.tag_type.outputs.version, 'dashboard/') }}
env:
APISIX_DASHBOARD_TAG_VERSION: ${{ steps.tag_env.outputs.version}}
run: |
# build apisix dashboard
make package type=rpm app=dashboard checkout=${APISIX_DASHBOARD_TAG_VERSION} version=${APISIX_DASHBOARD_TAG_VERSION} image_base=centos image_tag=7
make package type=rpm app=dashboard checkout=${APISIX_DASHBOARD_TAG_VERSION} version=${APISIX_DASHBOARD_TAG_VERSION} image_base=centos image_tag=8
mv ./output/apisix-dashboard-${APISIX_DASHBOARD_TAG_VERSION}-0.el{7,8}.x86_64.rpm ${VAR_RPM_WORKBENCH_DIR}
echo "TARGET_APP=apisix-dashboard" >> "$GITHUB_ENV"
- name: Upload apisix Artifact
if: ${{ startsWith(steps.tag_type.outputs.version, 'apisix/') }}
uses: actions/upload-artifact@v2.2.3
with:
name: "apisix-${{ steps.tag_env.outputs.version}}-0.el7.x86_64.rpm"
path: "${{ env.VAR_RPM_WORKBENCH_DIR }}/apisix-${{ steps.tag_env.outputs.version}}-0.el7.x86_64.rpm"
- name: Upload apisix-base Artifact
if: ${{ startsWith(steps.tag_type.outputs.version, 'apisix-base/') }}
uses: actions/upload-artifact@v2.2.3
with:
name: "apisix-base-${{ steps.tag_env.outputs.version}}-0.el7.x86_64.rpm"
path: "${{ env.VAR_RPM_WORKBENCH_DIR }}/apisix-base-${{ steps.tag_env.outputs.version}}-0.el7.x86_64.rpm"
- name: Upload apisix-dashboard Artifact
if: ${{ startsWith(steps.tag_type.outputs.version, 'dashboard/') }}
uses: actions/upload-artifact@v2.2.3
with:
name: "apisix-dashboard-${{ steps.tag_env.outputs.version}}-0.el7.x86_64.rpm"
path: "./apisix-dashboard-${{ steps.tag_env.outputs.version}}-0.el7.x86_64.rpm"
- name: RPM repo deps init
env:
TENCENT_COS_SECRETID: ${{ secrets.TENCENT_COS_SECRETID }}
TENCENT_COS_SECRETKEY: ${{ secrets.TENCENT_COS_SECRETKEY }}
run: |
sudo -E ./utils/publish-rpm.sh init_cos_utils
- name: RPM repo init
run: |
sudo -E ./utils/publish-rpm.sh repo_init
sudo -E ./utils/publish-rpm.sh repo_clone
- name: RPM repo package update
env:
GPG_NAME: ${{ secrets.GPG_NAME }}
GPG_MAIL: ${{ secrets.GPG_MAIL }}
run: |
echo "${{ secrets.RPM_GPG_PRIV_KEY }}" >> /tmp/rpm-gpg-publish.private
echo "${{ secrets.RPM_GPG_PASSPHRASE }}" >> /tmp/rpm-gpg-publish.passphrase
echo "${{ secrets.RPM_GPG_PUB_KEY }}" >> /tmp/rpm-gpg-publish.public
sudo -E ./utils/publish-rpm.sh rpm_gpg_sign
sudo -E ./utils/publish-rpm.sh repo_package_sync
- name: RPM repo backup
run: |
sudo -E ./utils/publish-rpm.sh repo_backup
- name: RPM repo refresh
run: |
sudo -E ./utils/publish-rpm.sh repo_repodata_rebuild
sudo -E ./utils/publish-rpm.sh repo_upload
- name: RPM repo remove backup
run: |
sudo -E ./utils/publish-rpm.sh repo_backup_remove
- name: RPM repo publish
run: |
sudo -E ./utils/publish-rpm.sh repo_publish