Compile the offline installation package #34
This file contains hidden or 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
| # Licensed to the Apache Software Foundation (ASF) under one | |
| # or more contributor license agreements. See the NOTICE file | |
| # distributed with this work for additional information | |
| # regarding copyright ownership. The ASF licenses this file | |
| # to you under the Apache License, Version 2.0 (the | |
| # "License"); you may not use this file except in compliance | |
| # with the License. You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, | |
| # software distributed under the License is distributed on an | |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| # KIND, either express or implied. See the License for the | |
| # specific language governing permissions and limitations | |
| # under the License. | |
| name: Compile the offline installation package | |
| # Controls when the workflow will run | |
| on: | |
| # Allows you to run this workflow manually from the Actions tab | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| cos_version: | |
| description: 'COS version (leave empty for default: v1.1.7)' | |
| required: false | |
| default: '' | |
| type: string | |
| colink_version: | |
| description: 'Colink version (leave empty for default: 1.0.4)' | |
| required: false | |
| default: '' | |
| type: string | |
| colistener_version: | |
| description: 'Colistener version (leave empty for default: 2.1.0-0)' | |
| required: false | |
| default: '' | |
| type: string | |
| cobridge_version: | |
| description: 'Cobridge version (leave empty for default: 1.1.0-0)' | |
| required: false | |
| default: '' | |
| type: string | |
| trzsz_version: | |
| description: 'Trzsz version (leave empty for default: 1.1.6)' | |
| required: false | |
| default: '' | |
| type: string | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get Version | |
| id: get_version | |
| run: | | |
| echo $(git describe --always --tags --abbrev=8 --dirty) | |
| echo "version=$(git describe --always --tags --abbrev=8 --dirty)" >> "$GITHUB_OUTPUT" | |
| outputs: | |
| version: ${{ steps.get_version.outputs.version }} | |
| package-zip-file: | |
| runs-on: ubuntu-latest | |
| needs: check | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Check if version is release or beta | |
| env: | |
| VERSION: ${{ needs.check.outputs.version }} | |
| run: | | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| if echo "$VERSION" | grep -q -E '^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$'; then | |
| echo "IS_RELEASE=true" >> $GITHUB_ENV | |
| echo "VERSION_TAG=latest" >> $GITHUB_ENV | |
| else | |
| echo "IS_RELEASE=false" >> $GITHUB_ENV | |
| echo "VERSION_TAG=beta" >> $GITHUB_ENV | |
| fi | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Build Tar gz file | |
| run: | | |
| chmod +x script/package.sh | |
| # Set up version arguments with defaults if inputs are empty | |
| COS_VERSION_ARG="" | |
| if [ -n "${{ github.event.inputs.cos_version }}" ]; then | |
| COS_VERSION_ARG="--cos_version=${{ github.event.inputs.cos_version }}" | |
| fi | |
| COLINK_VERSION_ARG="" | |
| if [ -n "${{ github.event.inputs.colink_version }}" ]; then | |
| COLINK_VERSION_ARG="--colink_version=${{ github.event.inputs.colink_version }}" | |
| fi | |
| COLISTENER_VERSION_ARG="" | |
| if [ -n "${{ github.event.inputs.colistener_version }}" ]; then | |
| COLISTENER_VERSION_ARG="--colistener_version=${{ github.event.inputs.colistener_version }}" | |
| fi | |
| COBRIDGE_VERSION_ARG="" | |
| if [ -n "${{ github.event.inputs.cobridge_version }}" ]; then | |
| COBRIDGE_VERSION_ARG="--cobridge_version=${{ github.event.inputs.cobridge_version }}" | |
| fi | |
| TRZSZ_VERSION_ARG="" | |
| if [ -n "${{ github.event.inputs.trzsz_version }}" ]; then | |
| TRZSZ_VERSION_ARG="--trzsz_version=${{ github.event.inputs.trzsz_version }}" | |
| fi | |
| # Run package script with version arguments | |
| script/package.sh \ | |
| --release_version=${{ env.VERSION }} \ | |
| --output_dir=$GITHUB_WORKSPACE \ | |
| --verbose \ | |
| $COS_VERSION_ARG \ | |
| $COLINK_VERSION_ARG \ | |
| $COLISTENER_VERSION_ARG \ | |
| $COBRIDGE_VERSION_ARG \ | |
| $TRZSZ_VERSION_ARG | |
| - name: Upload Tar gz beta file | |
| if: env.IS_RELEASE == 'false' | |
| uses: tvrcgo/oss-action@master | |
| with: | |
| key-id: ${{ secrets.OSS_ARTIFACTS_ACCESS_KEY }} | |
| key-secret: ${{ secrets.OSS_ARTIFACTS_ACCESS_SECRET }} | |
| region: oss-cn-hangzhou | |
| bucket: coscene-download | |
| assets: | | |
| /home/runner/work/edge-software/edge-software/cos_binaries.tar.gz:/cosbinary/tar/beta/cos_binaries.tar.gz | |
| /home/runner/work/edge-software/edge-software/cos_binaries.tar.gz:/cosbinary/tar/${{ env.VERSION }}/cos_binaries.tar.gz | |
| script/install.sh:/cosbinary/script/beta/install.sh | |
| script/install-proxy.sh:/cosbinary/script/beta/install-proxy.sh | |
| script/install-initd.sh:/cosbinary/script/beta/install-initd.sh | |
| script/uninstall.sh:/cosbinary/script/beta/uninstall.sh | |
| script/device-check.sh:/cosbinary/script/beta/device-check.sh | |
| - name: Upload Tar gz release file | |
| if: env.IS_RELEASE == 'true' | |
| uses: tvrcgo/oss-action@master | |
| with: | |
| key-id: ${{ secrets.OSS_ARTIFACTS_ACCESS_KEY }} | |
| key-secret: ${{ secrets.OSS_ARTIFACTS_ACCESS_SECRET }} | |
| region: oss-cn-hangzhou | |
| bucket: coscene-download | |
| assets: | | |
| /home/runner/work/edge-software/edge-software/cos_binaries.tar.gz:/cosbinary/tar/latest/cos_binaries.tar.gz | |
| /home/runner/work/edge-software/edge-software/cos_binaries.tar.gz:/cosbinary/tar/${{ env.VERSION }}/cos_binaries.tar.gz | |
| script/install.sh:/cosbinary/script/latest/install.sh | |
| script/install-proxy.sh:/cosbinary/script/latest/install-proxy.sh | |
| script/install-initd.sh:/cosbinary/script/latest/install-initd.sh | |
| script/uninstall.sh:/cosbinary/script/latest/uninstall.sh | |
| script/device-check.sh:/cosbinary/script/latest/device-check.sh | |
| - name: Replace download link in script/install.sh | |
| run: | | |
| sed -i "s#https://download.coscene.cn#https://coscene-download.s3.us-east-1.amazonaws.com#g" script/install.sh | |
| sed -i "s#https://apt.coscene.cn#https://apt.coscene.io#g" script/install.sh | |
| sed -i "s#https://download.coscene.cn#https://coscene-download.s3.us-east-1.amazonaws.com#g" script/install-initd.sh | |
| sed -i "s#https://apt.coscene.cn#https://apt.coscene.io#g" script/install-initd.sh | |
| sed -i "s#https://download.coscene.cn#https://coscene-download.s3.us-east-1.amazonaws.com#g" script/install-proxy.sh | |
| - name: Upload to S3 | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.S3_ARTIFACTS_ACCESS_KEY }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_ARTIFACTS_ACCESS_SECRET }} | |
| AWS_DEFAULT_REGION: 'us-east-1' | |
| run: | | |
| aws s3 cp $GITHUB_WORKSPACE/cos_binaries.tar.gz s3://coscene-download/cosbinary/tar/${{ env.VERSION }}/cos_binaries.tar.gz | |
| if [ "${{ env.IS_RELEASE }}" == "true" ]; then | |
| aws s3 cp $GITHUB_WORKSPACE/cos_binaries.tar.gz s3://coscene-download/cosbinary/tar/latest/cos_binaries.tar.gz | |
| aws s3 cp script/install.sh s3://coscene-download/cosbinary/script/latest/install.sh --content-type application/x-sh | |
| aws s3 cp script/install-proxy.sh s3://coscene-download/cosbinary/script/latest/install-proxy.sh --content-type application/x-sh | |
| aws s3 cp script/install-initd.sh s3://coscene-download/cosbinary/script/latest/install-initd.sh --content-type application/x-sh | |
| aws s3 cp script/uninstall-en.sh s3://coscene-download/cosbinary/script/latest/uninstall.sh --content-type application/x-sh | |
| aws s3 cp script/device-check-en.sh s3://coscene-download/cosbinary/script/latest/device-check.sh --content-type application/x-sh | |
| else | |
| aws s3 cp $GITHUB_WORKSPACE/cos_binaries.tar.gz s3://coscene-download/cosbinary/tar/beta/cos_binaries.tar.gz | |
| aws s3 cp script/install.sh s3://coscene-download/cosbinary/script/beta/install.sh --content-type application/x-sh | |
| aws s3 cp script/install-proxy.sh s3://coscene-download/cosbinary/script/beta/install-proxy.sh --content-type application/x-sh | |
| aws s3 cp script/install-initd.sh s3://coscene-download/cosbinary/script/beta/install-initd.sh --content-type application/x-sh | |
| aws s3 cp script/uninstall-en.sh s3://coscene-download/cosbinary/script/beta/uninstall.sh --content-type application/x-sh | |
| aws s3 cp script/device-check-en.sh s3://coscene-download/cosbinary/script/beta/device-check.sh --content-type application/x-sh | |
| fi | |
| - name: Upload to Release Assets | |
| if: env.IS_RELEASE == 'true' | |
| uses: actions/[email protected] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ github.event.release.upload_url }} | |
| asset_path: /home/runner/work/edge-software/edge-software/cos_binaries.tar.gz | |
| asset_name: cos_binaries.tar.gz | |
| asset_content_type: application/gzip |