Fix workflow (#311) #89
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
| name: Release | ||
| run-name: Release ${{ inputs.tag }} ${{ github.actor }} ${{ github.event_name }} | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| tag: | ||
| description: "The tag to release (v1.0.0-beta, v1.0.0)" | ||
| required: true | ||
| type: string | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: "The tag to release (v1.0.0-beta, v1.0.0)" | ||
| required: true | ||
| type: string | ||
| jobs: | ||
| get-configs: | ||
| uses: ./.github/workflows/configs.yml | ||
| version-and-tag: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| version: ${{ steps.get-version.outputs.version }} | ||
| tag: ${{ steps.validate-tag.outputs.tag }} | ||
| is-prerelease: ${{ steps.validate-tag.outputs.is-prerelease }} | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ inputs.tag }} | ||
| fetch-tags: true | ||
| - name: Get version from package.json | ||
| id: get-version | ||
| run: | | ||
| VERSION=$(node -p "require('./package.json').version") | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
| - name: Validate tag matches version | ||
| id: validate-tag | ||
| run: | | ||
| VERSION=${{ steps.get-version.outputs.version }} | ||
| TAG=${{ inputs.tag }} | ||
| if [[ "$TAG" == "v$VERSION" ]]; then | ||
| echo "tag=$TAG" >> $GITHUB_OUTPUT | ||
| echo "is-prerelease=false" >> $GITHUB_OUTPUT | ||
| elif [[ "$TAG" =~ ^v$VERSION-[0-9]{12}-alpha$ ]]; then | ||
| echo "tag=$TAG" >> $GITHUB_OUTPUT | ||
| echo "is-prerelease=true" >> $GITHUB_OUTPUT | ||
| elif [[ "$TAG" =~ ^v$VERSION-beta$ ]]; then | ||
| echo "tag=$TAG" >> $GITHUB_OUTPUT | ||
| echo "is-prerelease=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "Error: Tag ($TAG) must be v$VERSION, v$VERSION-yyyymmddhhmm-alpha, or v$VERSION-beta" | ||
| exit 1 | ||
| fi | ||
| build-and-test: | ||
| needs: [ get-configs, version-and-tag ] | ||
| uses: ./.github/workflows/build-and-test.yml | ||
| strategy: | ||
| fail-fast: true | ||
| matrix: | ||
| os: [ ubuntu-latest, windows-latest, macos-latest ] | ||
| with: | ||
| ref: ${{ needs.version-and-tag.outputs.tag }} | ||
| runs-on: ${{ matrix.os }} | ||
| bundle-linux-old: | ||
| needs: [ get-configs, version-and-tag, build-and-test ] | ||
| strategy: | ||
| fail-fast: true | ||
| matrix: | ||
| include: | ||
| - { arch: "x64", docker-platform: "linux/amd64", go-arch: "amd64", use_qemu: false, node-version: "18" } | ||
| - { arch: "arm64", docker-platform: "linux/arm64", go-arch: "arm64", use_qemu: true, node-version: "18" } | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ needs.version-and-tag.outputs.tag }} | ||
| fetch-tags: true | ||
| - name: Set release asset name | ||
| id: set-asset-name | ||
| shell: bash | ||
| run: | | ||
| APP_NAME=${{ needs.get-configs.outputs.app-name }} | ||
| VERSION=$(node -p "require('./package.json').version") | ||
| NODE_VERSION=${{ matrix.node-version }} | ||
| NODE_MAJOR=$(echo $NODE_VERSION | cut -d. -f1) | ||
| TAG=${{ needs.version-and-tag.outputs.tag }} | ||
| if [[ "$TAG" =~ -alpha$ ]]; then | ||
| FILE_NAME="${APP_NAME}-${VERSION}-alpha-glib2.28-linux-${{ matrix.arch }}-node${NODE_MAJOR}" | ||
| elif [[ "$TAG" =~ -beta$ ]]; then | ||
| FILE_NAME="${APP_NAME}-${VERSION}-beta-glib2.28-linux-${{ matrix.arch }}-node${NODE_MAJOR}" | ||
| else | ||
| FILE_NAME="${APP_NAME}-${VERSION}-glib2.28-linux-${{ matrix.arch }}-node${NODE_MAJOR}" | ||
| fi | ||
| ASSET_NAME=$(echo "$FILE_NAME" | tr '[:upper:]' '[:lower:]') | ||
| echo "ASSET_NAME=${ASSET_NAME}" >> $GITHUB_OUTPUT | ||
| - name: Set up QEMU | ||
| if: matrix.use_qemu | ||
| uses: docker/setup-qemu-action@v3 | ||
| - name: Bundle (${{ matrix.docker-platform }}-${{ matrix.node-version }}) | ||
| run: | | ||
| docker run --rm -t -v ${{ github.workspace }}:/work -w /work \ | ||
| --platform ${{ matrix.docker-platform }} \ | ||
| node:18-buster \ | ||
| /bin/bash -c ' | ||
| set -e | ||
| git config --global --add safe.directory /work | ||
| echo "deb http://archive.debian.org/debian buster main" > /etc/apt/sources.list | ||
| echo "deb http://archive.debian.org/debian-security buster/updates main" >> /etc/apt/sources.list | ||
| apt-get -o Acquire::Check-Valid-Until=false update | ||
| apt-get update | ||
| apt-get install -y make g++ python3 build-essential tar gzip wget tree | ||
| SYS_LIB=$(find /usr/lib -name libstdc++.so.6 | head -n 1) | ||
| SYS_MAX=$(strings "$SYS_LIB" | grep "GLIBCXX_[0-9]" | sort -V | tail -n 1) | ||
| SYS_MIN=$(strings "$SYS_LIB" | grep "GLIBCXX_[0-9]" | sort -V | head -n 1) | ||
| echo "----------------------------------------------------------------" | ||
| echo "SYSTEM BASELINE:" | ||
| echo "Library Path: $SYS_LIB" | ||
| echo "Max GLIBCXX Supported: $SYS_MAX" | ||
| echo "Min GLIBCXX Supported: $SYS_MIN" | ||
| echo "----------------------------------------------------------------" | ||
| wget -q https://go.dev/dl/go${{ needs.get-configs.outputs.go-version }}.linux-${{ matrix.go-arch }}.tar.gz | ||
| tar -C /usr/local -xzf go${{ needs.get-configs.outputs.go-version }}.linux-${{ matrix.go-arch }}.tar.gz | ||
| export PATH=$PATH:/usr/local/go/bin | ||
| uname -r && node -v && npm -v && go version | ||
| npm ci | ||
| TAG="${{ needs.version-and-tag.outputs.tag }}" | ||
| if [[ "$TAG" =~ -alpha$ ]]; then | ||
| npm run bundle:alpha -- --env rebuild=true | ||
| elif [[ "$TAG" =~ -beta$ ]]; then | ||
| npm run bundle:beta -- --env rebuild=true | ||
| else | ||
| npm run bundle:prod -- --env rebuild=true | ||
| fi | ||
| if [ -z "$(find . -name "*.node" -print -quit)" ]; then | ||
| echo "::warning::No .node files found to check" | ||
| exit 1 | ||
| else | ||
| find . -name "*.node" -print0 | while IFS= read -r -d "" file; do | ||
| echo "Inspecting: $file" | ||
| FILE_MAX=$(strings "$file" | grep "GLIBCXX_[0-9]" | sort -V | tail -n 1) | ||
| FILE_MIN=$(strings "$file" | grep "GLIBCXX_[0-9]" | sort -V | head -n 1) | ||
| echo " > FileMAX - $FILE_MAX FileMIN - $FILE_MIN" | ||
| done | ||
| fi | ||
| GOARCH=${{ matrix.go-arch }} go build -C ./cfn-init/cmd -v -o ../../bundle/production/bin/cfn-init | ||
| cp ./cfn-init/THIRD-PARTY-LICENSES.txt ./bundle/production/bin/ | ||
| ' | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ steps.set-asset-name.outputs.ASSET_NAME }} | ||
| path: bundle/production/ | ||
| if-no-files-found: error | ||
| include-hidden-files: true | ||
| compression-level: 6 | ||
| bundle: | ||
| needs: [ get-configs, version-and-tag, build-and-test ] | ||
| strategy: | ||
| fail-fast: true | ||
| matrix: | ||
| include: | ||
| - { os: "ubuntu-latest", arch: "x64", platform: "linux", go-arch: "amd64", node-version: "22.x" } | ||
| - { os: "ubuntu-24.04-arm", arch: "arm64", platform: "linux", go-arch: "arm64", node-version: "22.x" } | ||
| - { os: "macos-15-intel", arch: "x64", platform: "darwin", go-arch: "amd64", node-version: "22.x" } | ||
| - { os: "macos-latest", arch: "arm64", platform: "darwin", go-arch: "arm64", node-version: "22.x" } | ||
| - { os: "windows-latest", arch: "x64", platform: "win32", go-arch: "amd64", node-version: "22.x" } | ||
| - { os: "windows-11-arm", arch: "arm64", platform: "win32", go-arch: "arm64", node-version: "22.x" } | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ needs.version-and-tag.outputs.tag }} | ||
| fetch-tags: true | ||
| - name: Git Status | ||
| shell: bash | ||
| run: echo "Bundling from branch=$(git rev-parse --abbrev-ref HEAD), commit=$(git rev-parse HEAD), tag=$(git describe --tags --exact-match)" | ||
| - name: Setup Node.js ${{ matrix.node-version }} (${{ runner.os }}) | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
| - name: Setup Go ${{ needs.get-configs.outputs.go-version }} (${{ runner.os }}) | ||
| uses: actions/setup-go@v4 | ||
| with: | ||
| go-version: ${{ needs.get-configs.outputs.go-version }} | ||
| cache: true | ||
| - name: Install Dependencies | ||
| run: npm ci | ||
| - name: Bundle (${{ matrix.platform }}/${{ matrix.arch }}-${{ node-version }}) | ||
| shell: bash | ||
| run: | | ||
| TAG=${{ needs.version-and-tag.outputs.tag }} | ||
| if [[ "$TAG" =~ -alpha$ ]]; then | ||
| npm run bundle:alpha | ||
| elif [[ "$TAG" =~ -beta$ ]]; then | ||
| npm run bundle:beta | ||
| else | ||
| npm run bundle:prod | ||
| fi | ||
| - name: Bundle Go | ||
| shell: bash | ||
| env: | ||
| GOPROXY: direct | ||
| run: | | ||
| if [[ "${{ runner.os }}" == "Windows" ]]; then | ||
| GOARCH=${{ matrix.go-arch }} go build -C ./cfn-init/cmd -v -o ../../bundle/production/bin/cfn-init.exe | ||
| else | ||
| GOARCH=${{ matrix.go-arch }} go build -C ./cfn-init/cmd -v -o ../../bundle/production/bin/cfn-init | ||
| fi | ||
| cp ./cfn-init/THIRD-PARTY-LICENSES.txt ./bundle/production/bin/ | ||
| - name: Set release asset name | ||
| id: set-asset-name | ||
| shell: bash | ||
| run: | | ||
| APP_NAME=${{ needs.get-configs.outputs.app-name }} | ||
| VERSION=$(node -p "require('./package.json').version") | ||
| PLATFORM=${{ matrix.platform }} | ||
| ARCH=${{ matrix.arch }} | ||
| NODE_VERSION=${{ matrix.node-version }} | ||
| NODE_MAJOR=$(echo $NODE_VERSION | cut -d. -f1) | ||
| TAG=${{ needs.version-and-tag.outputs.tag }} | ||
| if [[ "$TAG" =~ -alpha$ ]]; then | ||
| FILE_NAME="${APP_NAME}-${VERSION}-alpha-${PLATFORM}-${ARCH}-node${NODE_MAJOR}" | ||
| elif [[ "$TAG" =~ -beta$ ]]; then | ||
| FILE_NAME="${APP_NAME}-${VERSION}-beta-${PLATFORM}-${ARCH}-node${NODE_MAJOR}" | ||
| else | ||
| FILE_NAME="${APP_NAME}-${VERSION}-${PLATFORM}-${ARCH}-node${NODE_MAJOR}" | ||
| fi | ||
| ASSET_NAME=$(echo "$FILE_NAME" | tr '[:upper:]' '[:lower:]') | ||
| echo "ASSET_NAME=${ASSET_NAME}" | ||
| echo "ASSET_NAME=${ASSET_NAME}" >> $GITHUB_OUTPUT | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ steps.set-asset-name.outputs.ASSET_NAME }} | ||
| path: bundle/production/ | ||
| if-no-files-found: error | ||
| include-hidden-files: true | ||
| compression-level: 6 | ||
| release: | ||
| needs: [ version-and-tag, bundle-linux-old, bundle ] | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Download all artifacts | ||
| uses: actions/download-artifact@v5 | ||
| with: | ||
| path: artifacts | ||
| extract: false | ||
| - name: Create zip files for release | ||
| run: | | ||
| ls -R artifacts/ | ||
| cd artifacts | ||
| for dir in */; do | ||
| dirname="${dir%/}" | ||
| echo "Creating ${dirname}.zip" | ||
| (cd "$dirname" && zip -r "../${dirname}.zip" .) | ||
| rm -rf "$dirname" | ||
| done | ||
| ls -lh *.zip | ||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: ${{ needs.version-and-tag.outputs.tag }} | ||
| prerelease: ${{ needs.version-and-tag.outputs.is-prerelease }} | ||
| files: artifacts/*.zip | ||
| generate_release_notes: true | ||
| fail_on_unmatched_files: true | ||