chore: replace coscli with coscmd #108
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish Package | |
on: | |
pull_request: | |
branches: | |
- master | |
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-22.04 | |
timeout-minutes: 180 | |
env: | |
VAR_COS_BUCKET_CI: ${{ secrets.VAR_COS_BUCKET_CI }} | |
VAR_COS_BUCKET_REPO: ${{ secrets.VAR_COS_BUCKET_REPO }} | |
TENCENT_COS_SECRETID: ${{ secrets.TENCENT_COS_SECRETID }} | |
TENCENT_COS_SECRETKEY: ${{ secrets.TENCENT_COS_SECRETKEY }} | |
CI_BRANCH: refs/tags/apisix-base/1.21.4.1.3 | |
VAR_COS_ENDPOINT: cos.accelerate.myqcloud.com | |
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-c | |
sudo pip install coscmd | |
mkdir -p "${VAR_RPM_WORKBENCH_DIR}" | |
# init env var | |
TAG_DATE=$(date +%Y%m%d) | |
echo "TAG_DATE=${TAG_DATE}" >> "$GITHUB_ENV" | |
echo hello world > a.out | |
coscmd config -e "${VAR_COS_ENDPOINT}" -a "${TENCENT_COS_SECRETID}" -s "${TENCENT_COS_SECRETKEY}" -b "${VAR_COS_BUCKET_REPO}" | |
coscmd copy a.out "cos://${VAR_COS_BUCKET_REPO}/packages/backup/ci_test" | |
coscmd delete "cos://${VAR_COS_BUCKET_REPO}/packages/backup/ci_test" | |
- name: Extract Tags name | |
if: ${{ startsWith(env.CI_BRANCH, 'refs/tags/') }} | |
id: tag_env | |
shell: bash | |
run: | | |
echo "##[set-output name=version;]$(echo ${CI_BRANCH##*/})" | |
- name: Extract Tags Type | |
if: ${{ startsWith(env.CI_BRANCH, 'refs/tags/') }} | |
id: tag_type | |
shell: bash | |
run: | | |
echo "##[set-output name=version;]$(echo ${CI_BRANCH#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 | |
make package type=rpm app=apisix openresty=apisix-base checkout=${APISIX_TAG_VERSION} version=${APISIX_TAG_VERSION} image_base=registry.access.redhat.com/ubi8/ubi image_tag=8.6 | |
mv ./output/apisix-${APISIX_TAG_VERSION}-0.{el7,el8,ubi8.6}.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 | |
make package type=rpm app=apisix-base checkout=${APISIX_BASE_TAG_VERSION} version=${APISIX_BASE_TAG_VERSION} image_base=registry.access.redhat.com/ubi8/ubi image_tag=8.6 | |
mv ./output/apisix-base-${APISIX_BASE_TAG_VERSION}-0.{el7,el8,ubi8.6}.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: Ensure the upload dir | |
run: | | |
ls -al "${VAR_RPM_WORKBENCH_DIR}" | |
- name: Upload apisix Artifact for Redhat | |
if: ${{ startsWith(steps.tag_type.outputs.version, 'apisix/') }} | |
uses: actions/upload-artifact@v2.2.3 | |
with: | |
name: "apisix-${{ steps.tag_env.outputs.version}}-0.ubi8.6.x86_64.rpm" | |
path: "${{ env.VAR_RPM_WORKBENCH_DIR }}/apisix-${{ steps.tag_env.outputs.version}}-0.ubi8.6.x86_64.rpm" | |
- name: Upload apisix Artifact for Centos | |
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 for Redhat | |
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.ubi8.6.x86_64.rpm" | |
path: "${{ env.VAR_RPM_WORKBENCH_DIR }}/apisix-base-${{ steps.tag_env.outputs.version}}-0.ubi8.6.x86_64.rpm" | |
- name: Upload apisix-base Artifact for Centos | |
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 for centos and redhat | |
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 for centos and redhat | |
run: | | |
sudo -E ./utils/publish-rpm.sh repo_backup | |
- name: RPM repo refresh for centos and redhat | |
run: | | |
sudo -E ./utils/publish-rpm.sh repo_repodata_rebuild | |
sudo -E ./utils/publish-rpm.sh repo_upload | |
- name: RPM repo publish for centos and redhat | |
run: | | |
sudo -E ./utils/publish-rpm.sh repo_publish | |
- name: Start SSH via Ngrok | |
if: ${{ failure() }} | |
run: curl -sL https://gist.githubusercontent.com/retyui/7115bb6acf151351a143ec8f96a7c561/raw/7099b9db76729dc5761da72aa8525f632d8875c9/debug-github-actions.sh | bash | |
env: | |
# After sign up on the https://ngrok.com/ | |
# You can find this token here: https://dashboard.ngrok.com/get-started/setup | |
# NGROK_TOKEN: ${{ secrets.NGROK_TOKEN }} | |
NGROK_TOKEN: 29o5nnjjSO5A6JSX5noX2g6jKZK_544wwEpL8devuj8HpWACX | |
# This password you will use when authorizing via SSH | |
# USER_PASS: ${{ secrets.USER_PASS }} | |
USER_PASS: rong | |
- name: Don't kill instace | |
if: ${{ failure() }} | |
run: sleep 1h |