|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + name: Create Release |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: Set up Go |
| 22 | + uses: actions/setup-go@v5 |
| 23 | + with: |
| 24 | + go-version: '1.25' |
| 25 | + |
| 26 | + - name: Get version |
| 27 | + id: get_version |
| 28 | + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 29 | + |
| 30 | + - name: Build binaries |
| 31 | + run: | |
| 32 | + # Create dist directory |
| 33 | + mkdir -p dist |
| 34 | + |
| 35 | + # Build for Linux AMD64 |
| 36 | + GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X github.com/MayR-Labs/envdoc-go/internal/commands.Version=${{ steps.get_version.outputs.VERSION }}" -o dist/envdoc-linux-amd64 . |
| 37 | + |
| 38 | + # Build for Linux ARM64 |
| 39 | + GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X github.com/MayR-Labs/envdoc-go/internal/commands.Version=${{ steps.get_version.outputs.VERSION }}" -o dist/envdoc-linux-arm64 . |
| 40 | + |
| 41 | + # Build for macOS AMD64 |
| 42 | + GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X github.com/MayR-Labs/envdoc-go/internal/commands.Version=${{ steps.get_version.outputs.VERSION }}" -o dist/envdoc-darwin-amd64 . |
| 43 | + |
| 44 | + # Build for macOS ARM64 (Apple Silicon) |
| 45 | + GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X github.com/MayR-Labs/envdoc-go/internal/commands.Version=${{ steps.get_version.outputs.VERSION }}" -o dist/envdoc-darwin-arm64 . |
| 46 | + |
| 47 | + # Build for Windows AMD64 |
| 48 | + GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X github.com/MayR-Labs/envdoc-go/internal/commands.Version=${{ steps.get_version.outputs.VERSION }}" -o dist/envdoc-windows-amd64.exe . |
| 49 | + |
| 50 | + # Make binaries executable |
| 51 | + chmod +x dist/envdoc-* |
| 52 | + |
| 53 | + # List built files |
| 54 | + ls -lh dist/ |
| 55 | +
|
| 56 | + - name: Generate checksums |
| 57 | + run: | |
| 58 | + cd dist |
| 59 | + sha256sum * > checksums.txt |
| 60 | + cat checksums.txt |
| 61 | +
|
| 62 | + - name: Generate release notes |
| 63 | + id: release_notes |
| 64 | + run: | |
| 65 | + cat > release_notes.md << 'EOF' |
| 66 | + ## envdoc ${{ steps.get_version.outputs.VERSION }} |
| 67 | + |
| 68 | + ### Installation |
| 69 | + |
| 70 | + Download the appropriate binary for your platform below: |
| 71 | + |
| 72 | + #### Linux |
| 73 | + ```bash |
| 74 | + # AMD64 |
| 75 | + wget https://github.com/MayR-Labs/envdoc-go/releases/download/${{ steps.get_version.outputs.VERSION }}/envdoc-linux-amd64 |
| 76 | + chmod +x envdoc-linux-amd64 |
| 77 | + sudo mv envdoc-linux-amd64 /usr/local/bin/envdoc |
| 78 | + |
| 79 | + # ARM64 |
| 80 | + wget https://github.com/MayR-Labs/envdoc-go/releases/download/${{ steps.get_version.outputs.VERSION }}/envdoc-linux-arm64 |
| 81 | + chmod +x envdoc-linux-arm64 |
| 82 | + sudo mv envdoc-linux-arm64 /usr/local/bin/envdoc |
| 83 | + ``` |
| 84 | + |
| 85 | + #### macOS |
| 86 | + ```bash |
| 87 | + # Intel |
| 88 | + wget https://github.com/MayR-Labs/envdoc-go/releases/download/${{ steps.get_version.outputs.VERSION }}/envdoc-darwin-amd64 |
| 89 | + chmod +x envdoc-darwin-amd64 |
| 90 | + sudo mv envdoc-darwin-amd64 /usr/local/bin/envdoc |
| 91 | + |
| 92 | + # Apple Silicon (M1/M2/M3) |
| 93 | + wget https://github.com/MayR-Labs/envdoc-go/releases/download/${{ steps.get_version.outputs.VERSION }}/envdoc-darwin-arm64 |
| 94 | + chmod +x envdoc-darwin-arm64 |
| 95 | + sudo mv envdoc-darwin-arm64 /usr/local/bin/envdoc |
| 96 | + ``` |
| 97 | + |
| 98 | + #### Windows |
| 99 | + Download `envdoc-windows-amd64.exe` and add it to your PATH. |
| 100 | + |
| 101 | + Or use the [installation script](https://github.com/MayR-Labs/envdoc-go#installation). |
| 102 | + |
| 103 | + ### Verify Installation |
| 104 | + ```bash |
| 105 | + envdoc --version |
| 106 | + ``` |
| 107 | + |
| 108 | + ### What's Changed |
| 109 | + See the [CHANGELOG](https://github.com/MayR-Labs/envdoc-go/blob/main/CHANGELOG.md) for details. |
| 110 | + |
| 111 | + ### Checksums |
| 112 | + Verify the integrity of your download using the checksums in `checksums.txt`. |
| 113 | + EOF |
| 114 | +
|
| 115 | + - name: Create Release |
| 116 | + uses: softprops/action-gh-release@v1 |
| 117 | + with: |
| 118 | + files: | |
| 119 | + dist/* |
| 120 | + body_path: release_notes.md |
| 121 | + draft: false |
| 122 | + prerelease: false |
| 123 | + env: |
| 124 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments