Improve URL extension detection to handle redirect URLs (#63) #17
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
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to release' | |
| required: true | |
| default: 'v0.1.0' | |
| jobs: | |
| build: | |
| name: Build binaries | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| # Linux | |
| - goos: linux | |
| goarch: amd64 | |
| suffix: '' | |
| - goos: linux | |
| goarch: arm64 | |
| suffix: '' | |
| # macOS | |
| - goos: darwin | |
| goarch: amd64 | |
| suffix: '' | |
| - goos: darwin | |
| goarch: arm64 | |
| suffix: '' | |
| # Windows | |
| - goos: windows | |
| goarch: amd64 | |
| suffix: '.exe' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup mvx | |
| run: | | |
| curl -fsSL https://raw.githubusercontent.com/gnodet/mvx/main/install-wrapper.sh | bash | |
| ./mvx setup | |
| - name: Get version | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| VERSION="${{ github.event.inputs.tag }}" | |
| else | |
| VERSION="${GITHUB_REF#refs/tags/}" | |
| fi | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "version_no_v=${VERSION#v}" >> $GITHUB_OUTPUT | |
| - name: Build binary | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| # Use CGO_ENABLED=1 for macOS to avoid security restrictions, 0 for others | |
| CGO_ENABLED: ${{ matrix.goos == 'darwin' && '1' || '0' }} | |
| run: | | |
| BINARY_NAME="mvx-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}" | |
| ./mvx go build \ | |
| -ldflags "-s -w -X main.Version=${{ steps.version.outputs.version_no_v }} -X main.Commit=${{ github.sha }} -X main.Date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ | |
| -o "dist/${BINARY_NAME}" \ | |
| . | |
| # Create checksums | |
| cd dist | |
| sha256sum "${BINARY_NAME}" > "${BINARY_NAME}.sha256" | |
| echo "Built: ${BINARY_NAME}" | |
| ls -la "${BINARY_NAME}"* | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mvx-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: | | |
| dist/mvx-${{ matrix.goos }}-${{ matrix.goarch }}* | |
| retention-days: 1 | |
| release: | |
| name: Create release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get version | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| VERSION="${{ github.event.inputs.tag }}" | |
| else | |
| VERSION="${GITHUB_REF#refs/tags/}" | |
| fi | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "version_no_v=${VERSION#v}" >> $GITHUB_OUTPUT | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare release assets | |
| run: | | |
| mkdir -p release | |
| find artifacts -name "mvx-*" -type f -exec cp {} release/ \; | |
| # Create combined checksums file | |
| cd release | |
| cat *.sha256 > checksums.txt | |
| echo "Release assets:" | |
| ls -la | |
| - name: Generate release notes | |
| run: | | |
| # Make sure the changelog script is executable | |
| chmod +x ./scripts/generate-changelog.sh | |
| # Get the current tag being released | |
| CURRENT_TAG="${{ steps.version.outputs.version }}" | |
| # Get the previous tag (excluding the current one) | |
| # Sort tags by version and get the one before current | |
| PREVIOUS_TAG=$(git tag -l 'v*' --sort=-version:refname | grep -v "^${CURRENT_TAG}$" | head -n 1) | |
| # Generate the changelog section | |
| if [ -n "$PREVIOUS_TAG" ]; then | |
| echo "Generating changelog from $PREVIOUS_TAG to $CURRENT_TAG" | |
| CHANGELOG=$(./scripts/generate-changelog.sh "$PREVIOUS_TAG" "$CURRENT_TAG") | |
| else | |
| echo "No previous tag found, using generic changelog" | |
| CHANGELOG="## 🚀 What's New | |
| This is the first release of mvx!" | |
| fi | |
| # Create the complete release notes | |
| cat > release_notes.md << EOF | |
| ## mvx ${{ steps.version.outputs.version_no_v }} | |
| $CHANGELOG | |
| ### 🚀 Installation | |
| **Using the wrapper (recommended):** | |
| \`\`\`bash | |
| curl -fsSL https://raw.githubusercontent.com/gnodet/mvx/main/install-wrapper.sh | bash | |
| ./mvx version | |
| \`\`\` | |
| **Direct download:** | |
| \`\`\`bash | |
| # Linux x64 | |
| curl -fsSL https://github.com/gnodet/mvx/releases/download/${{ steps.version.outputs.version }}/mvx-linux-amd64 -o mvx | |
| chmod +x mvx | |
| # macOS x64 | |
| curl -fsSL https://github.com/gnodet/mvx/releases/download/${{ steps.version.outputs.version }}/mvx-darwin-amd64 -o mvx | |
| chmod +x mvx | |
| # Windows x64 | |
| curl -fsSL https://github.com/gnodet/mvx/releases/download/${{ steps.version.outputs.version }}/mvx-windows-amd64.exe -o mvx.exe | |
| \`\`\` | |
| ### 📦 Assets | |
| | Platform | Architecture | Binary | Checksum | | |
| |----------|--------------|--------|----------| | |
| | Linux | x64 | \`mvx-linux-amd64\` | \`mvx-linux-amd64.sha256\` | | |
| | Linux | ARM64 | \`mvx-linux-arm64\` | \`mvx-linux-arm64.sha256\` | | |
| | macOS | x64 | \`mvx-darwin-amd64\` | \`mvx-darwin-amd64.sha256\` | | |
| | macOS | ARM64 | \`mvx-darwin-arm64\` | \`mvx-darwin-arm64.sha256\` | | |
| | Windows | x64 | \`mvx-windows-amd64.exe\` | \`mvx-windows-amd64.exe.sha256\` | | |
| ### 🔐 Verification | |
| Verify checksums: | |
| \`\`\`bash | |
| curl -fsSL https://github.com/gnodet/mvx/releases/download/${{ steps.version.outputs.version }}/checksums.txt | |
| sha256sum -c checksums.txt | |
| \`\`\` | |
| EOF | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.version }} | |
| name: mvx ${{ steps.version.outputs.version_no_v }} | |
| body_path: release_notes.md | |
| files: release/* | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |