Build & Release AWSCLI-Addons v3.1.3 by @MaksymLeus #16
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: Build & Release AWSCLI-Addons | |
| run-name: "Build & Release AWSCLI-Addons v${{ inputs.version || github.ref_name }} by @${{ github.actor }}" | |
| on: | |
| push: | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version (e.g., v1.2.3)' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| packages: write | |
| actions: read | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, ubuntu-24.04-arm, macos-15-intel, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: 'pip' | |
| - name: Detect OS and ARCH | |
| id: info | |
| shell: bash | |
| run: | | |
| # Detect OS (linux, darwin) | |
| OS=$(uname -s | tr '[:upper:]' '[:lower:]') | |
| # Detect Arch (amd64, arm64) | |
| ARCH=$(uname -m) | |
| [ "$ARCH" == "x86_64" ] && ARCH="amd64" | |
| [ "$ARCH" == "aarch64" ] && ARCH="arm64" | |
| # Set the output variable | |
| echo "artifact_name=awscli-addons-${OS}-${ARCH}" >> $GITHUB_OUTPUT | |
| - name: Run Build Script | |
| shell: bash | |
| run: | | |
| VERSION="${{ github.event.inputs.version }}" | |
| ./tools/build.sh quick "${VERSION}" | |
| # Move the binary to the unique name defined above | |
| mv dist/awscli-addons "dist/${{ steps.info.outputs.artifact_name }}" | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.info.outputs.artifact_name }} | |
| path: dist/${{ steps.info.outputs.artifact_name }} | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download All Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./artifacts | |
| pattern: awscli-addons-* | |
| merge-multiple: true | |
| - name: Generate checksums | |
| run: | | |
| cd artifacts | |
| sha256sum awscli-addons-* > checksums.txt | |
| cat checksums.txt | |
| - name: Create Manual Instructions | |
| id: manual_notes | |
| run: | | |
| # 1. Handle Versioning (Input vs Tag) | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| TARGET_COMMIT="${{ github.sha }}" | |
| else | |
| VERSION="${GITHUB_REF#refs/tags/}" | |
| TARGET_COMMIT="${VERSION}" | |
| fi | |
| FILE_NAME="manual_notes.md" | |
| # 2. Get previous tag. If none exists, get the first commit | |
| PREV_TAG=$(git describe --tags --abbrev=0 "${VERSION}^" 2>/dev/null || git rev-list --max-parents=0 HEAD) | |
| REPO_URL="https://github.com/${{ github.repository }}" | |
| cat > ${FILE_NAME} << EOF | |
| # π Release ${VERSION} | |
| ## π¦ Installation | |
| Install the latest binary for your system instantly: | |
| \`\`\`bash | |
| curl -sSL https://raw.githubusercontent.com/${{ github.repository }}/main/tools/installer.sh | bash | |
| \`\`\` | |
| ## ποΈ Available Binaries | |
| | Platform | Architecture | Binary | | |
| |----------|--------------|--------| | |
| | Linux | AMD64 | [linux-amd64](${REPO_URL}/releases/download/${VERSION}/awscli-addons-linux-amd64) | | |
| | Linux | ARM64 | [linux-arm64](${REPO_URL}/releases/download/${VERSION}/awscli-addons-linux-arm64) | | |
| | macOS | AMD64 | [macos-amd64](${REPO_URL}/releases/download/${VERSION}/awscli-addons-macos-amd64) | | |
| | macOS | ARM64 | [macos-arm64](${REPO_URL}/releases/download/${VERSION}/awscli-addons-macos-arm64) | | |
| Download the appropriate binary for your platform and make it executable: | |
| \`\`\`bash | |
| wget ${REPO_URL}/releases/download/${VERSION}/<Binary> | |
| #or | |
| curl ${REPO_URL}/releases/download/${VERSION}/<Binary> | |
| chmod +x <Binary> | |
| sudo mv <Binary> /usr/local/bin/<Binary> | |
| \`\`\` | |
| ## π‘οΈ Verification | |
| \`\`\`bash | |
| sha256sum -c checksums.txt | |
| \`\`\` | |
| ## π What's Changed | |
| EOF | |
| # 3. Generate changelog between previous tag and current commit | |
| git log ${PREV_TAG}..${TARGET_COMMIT} --oneline --pretty=format:"* %s (%h)" >> ${FILE_NAME} | |
| - name: Publish Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ github.event.inputs.version || github.ref_name }} | |
| body_path: manual_notes.md | |
| append_body: true # β This attaches GitHub's notes BELOW yours | |
| generate_release_notes: true # β This triggers the auto-generation | |
| files: | | |
| ./artifacts/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # - name: Create or update GitHub Release | |
| # uses: ncipollo/release-action@v1 | |
| # with: | |
| # tag: latest | |
| # name: Latest Release | |
| # draft: false | |
| # prerelease: false | |
| # artifacts: dist/* |