Merge 'feature/update_cli' into 'master' #67
Workflow file for this run
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
| # This GitHub action can publish assets for release when a tag is created. | |
| # Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0). | |
| # | |
| # This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your | |
| # private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE` | |
| # secret. If you would rather own your own GPG handling, please fork this action | |
| # or use an alternative one for key handling. | |
| # | |
| # You will need to pass the `--batch` flag to `gpg` in your signing step | |
| # in `goreleaser` to indicate this is being used in a non-interactive mode. | |
| # | |
| name: release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: 1.17 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org | |
| - name: Extract version | |
| id: version | |
| run: | | |
| tag="${GITHUB_REF_NAME}" | |
| version="${tag#v}" | |
| if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then | |
| echo "Invalid release tag: $tag" >&2 | |
| exit 1 | |
| fi | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@v3.0.0 | |
| with: | |
| version: v1.26.2 | |
| args: release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install AWS CLI | |
| run: | | |
| python3 -m pip install --user --upgrade awscli | |
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" | |
| - name: Upload release assets to TOS | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.TOS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.TOS_SECRET_ACCESS_KEY }} | |
| AWS_MAX_ATTEMPTS: "2" | |
| AWS_CLI_CONNECT_TIMEOUT: "10" | |
| AWS_CLI_READ_TIMEOUT: "60" | |
| TOS_BUCKET: ${{ vars.TOS_BUCKET }} | |
| TOS_PREFIX: ${{ vars.TOS_PREFIX }} | |
| TOS_REGION: ${{ vars.TOS_REGION }} | |
| TOS_S3_ENDPOINT: ${{ vars.TOS_S3_ENDPOINT }} | |
| TOS_UPLOAD_CONCURRENCY: ${{ vars.TOS_UPLOAD_CONCURRENCY }} | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| : "${AWS_ACCESS_KEY_ID:?missing secret TOS_ACCESS_KEY_ID}" | |
| : "${AWS_SECRET_ACCESS_KEY:?missing secret TOS_SECRET_ACCESS_KEY}" | |
| export AWS_DEFAULT_REGION="${TOS_REGION:-cn-beijing}" | |
| bucket="${TOS_BUCKET:-eps-common-public}" | |
| prefix="${TOS_PREFIX:-ve}" | |
| endpoint="${TOS_S3_ENDPOINT:-https://tos-s3-cn-beijing.volces.com}" | |
| concurrency="${TOS_UPLOAD_CONCURRENCY:-20}" | |
| destination="s3://${bucket}/${prefix}/v${VERSION}/" | |
| if ! [[ "$concurrency" =~ ^[1-9][0-9]*$ ]]; then | |
| echo "Invalid TOS_UPLOAD_CONCURRENCY: $concurrency" >&2 | |
| exit 1 | |
| fi | |
| aws configure set default.s3.addressing_style virtual | |
| find dist -maxdepth 1 -type f \( -name '*.zip' -o -name '*SHA256SUMS' \) -print | |
| aws --endpoint-url "$endpoint" s3 ls "s3://${bucket}/${prefix}/" || true | |
| pids=() | |
| while IFS= read -r file; do | |
| echo "Uploading ${file}" | |
| aws --endpoint-url "$endpoint" s3 cp "$file" "$destination" & | |
| pids+=("$!") | |
| if [ "${#pids[@]}" -ge "$concurrency" ]; then | |
| for pid in "${pids[@]}"; do | |
| wait "$pid" | |
| done | |
| pids=() | |
| fi | |
| done < <(find dist -maxdepth 1 -type f \( -name '*.zip' -o -name '*SHA256SUMS' \) -print | sort) | |
| for pid in "${pids[@]}"; do | |
| wait "$pid" | |
| done | |
| aws --endpoint-url "$endpoint" s3 ls "$destination" --recursive | |
| - name: Configure npm package for TOS | |
| env: | |
| TOS_PREFIX: ${{ vars.TOS_PREFIX }} | |
| TOS_PUBLIC_BASE_URL: ${{ vars.TOS_PUBLIC_BASE_URL }} | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| prefix="${TOS_PREFIX:-ve}" | |
| public_base="${TOS_PUBLIC_BASE_URL:-https://cloudcache.volccdn.com}" | |
| download_base="${public_base%/}/${prefix}" | |
| node scripts/configure_npm_release.js "$VERSION" "$download_base" | |
| - name: Verify public TOS download | |
| env: | |
| TOS_PREFIX: ${{ vars.TOS_PREFIX }} | |
| TOS_PUBLIC_BASE_URL: ${{ vars.TOS_PUBLIC_BASE_URL }} | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| prefix="${TOS_PREFIX:-ve}" | |
| public_base="${TOS_PUBLIC_BASE_URL:-https://cloudcache.volccdn.com}" | |
| download_base="${public_base%/}/${prefix}" | |
| archive="volcengine-cli_${VERSION}_linux_amd64.zip" | |
| curl --fail --location --head "${download_base}/v${VERSION}/${archive}" | |
| - name: Test npm package | |
| working-directory: npm | |
| run: | | |
| npm test | |
| npm pack --dry-run | |
| - name: Publish npm package | |
| working-directory: npm | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| : "${NODE_AUTH_TOKEN:?missing secret NPM_TOKEN}" | |
| npm_tag="latest" | |
| if [[ "$VERSION" == *-* ]]; then | |
| npm_tag="next" | |
| fi | |
| npm publish --access public --tag "$npm_tag" |