Merge pull request #7 from universal-development/a482dependabot/githu… #20
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: CI/CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to release (e.g., v1.0.0)' | |
| required: true | |
| type: string | |
| draft: | |
| description: 'Create as draft release' | |
| required: false | |
| type: boolean | |
| default: false | |
| prerelease: | |
| description: 'Mark as pre-release' | |
| required: false | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '1.25' | |
| - name: Install just | |
| uses: extractions/setup-just@v3 | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Verify dependencies | |
| run: just verify | |
| - name: Run tests with coverage | |
| run: just test-coverage | |
| - name: Display coverage | |
| run: go tool cover -func=coverage.out | |
| - name: Upload coverage to artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: coverage-report | |
| path: coverage.out | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '1.25' | |
| - name: Install just | |
| uses: extractions/setup-just@v3 | |
| - name: Get version | |
| id: version | |
| run: | | |
| VERSION=$(just version) | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Building version: $VERSION" | |
| - name: Build for all platforms | |
| run: just build-all | |
| - name: Generate checksums | |
| run: | | |
| cd dist | |
| sha256sum * > checksums.txt | |
| cat checksums.txt | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: binaries | |
| path: dist/ | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine release type | |
| id: release_type | |
| run: | | |
| # Get tag name from either push or workflow_dispatch | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| TAG="${{ github.event.inputs.tag }}" | |
| DRAFT="${{ github.event.inputs.draft }}" | |
| PRERELEASE="${{ github.event.inputs.prerelease }}" | |
| else | |
| TAG="${{ github.ref_name }}" | |
| DRAFT="false" | |
| # Auto-detect pre-release from tag name | |
| if echo "$TAG" | grep -qE '(alpha|beta|rc|pre|preview|dev)'; then | |
| PRERELEASE="true" | |
| else | |
| PRERELEASE="false" | |
| fi | |
| fi | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "draft=$DRAFT" >> $GITHUB_OUTPUT | |
| echo "prerelease=$PRERELEASE" >> $GITHUB_OUTPUT | |
| echo "Release Configuration:" | |
| echo " Tag: $TAG" | |
| echo " Draft: $DRAFT" | |
| echo " Pre-release: $PRERELEASE" | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: binaries | |
| path: dist/ | |
| - name: Set executable permissions | |
| run: | | |
| chmod +x dist/go-getter-file-* | |
| ls -lh dist/ | |
| - name: Create release archives | |
| run: | | |
| cd dist | |
| TAG="${{ steps.release_type.outputs.tag }}" | |
| # Linux amd64 | |
| tar czf go-getter-file-$TAG-linux-amd64.tar.gz go-getter-file-linux-amd64 | |
| # Linux arm64 | |
| tar czf go-getter-file-$TAG-linux-arm64.tar.gz go-getter-file-linux-arm64 | |
| # macOS amd64 | |
| tar czf go-getter-file-$TAG-darwin-amd64.tar.gz go-getter-file-darwin-amd64 | |
| # macOS arm64 | |
| tar czf go-getter-file-$TAG-darwin-arm64.tar.gz go-getter-file-darwin-arm64 | |
| # Windows amd64 | |
| zip go-getter-file-$TAG-windows-amd64.zip go-getter-file-windows-amd64.exe | |
| # Update checksums with archives | |
| sha256sum *.tar.gz *.zip > checksums.txt | |
| ls -lh | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.release_type.outputs.tag }} | |
| files: | | |
| dist/go-getter-file-${{ steps.release_type.outputs.tag }}-linux-amd64.tar.gz | |
| dist/go-getter-file-${{ steps.release_type.outputs.tag }}-linux-arm64.tar.gz | |
| dist/go-getter-file-${{ steps.release_type.outputs.tag }}-darwin-amd64.tar.gz | |
| dist/go-getter-file-${{ steps.release_type.outputs.tag }}-darwin-arm64.tar.gz | |
| dist/go-getter-file-${{ steps.release_type.outputs.tag }}-windows-amd64.zip | |
| dist/checksums.txt | |
| draft: ${{ steps.release_type.outputs.draft }} | |
| prerelease: ${{ steps.release_type.outputs.prerelease }} | |
| generate_release_notes: true | |
| body: | | |
| ## Installation | |
| Download the appropriate binary for your platform from the assets below. | |
| ### Linux | |
| ```bash | |
| # AMD64 | |
| wget https://github.com/${{ github.repository }}/releases/download/${{ steps.release_type.outputs.tag }}/go-getter-file-${{ steps.release_type.outputs.tag }}-linux-amd64.tar.gz | |
| tar xzf go-getter-file-${{ steps.release_type.outputs.tag }}-linux-amd64.tar.gz | |
| chmod +x go-getter-file-linux-amd64 | |
| sudo mv go-getter-file-linux-amd64 /usr/local/bin/go-getter-file | |
| # ARM64 | |
| wget https://github.com/${{ github.repository }}/releases/download/${{ steps.release_type.outputs.tag }}/go-getter-file-${{ steps.release_type.outputs.tag }}-linux-arm64.tar.gz | |
| tar xzf go-getter-file-${{ steps.release_type.outputs.tag }}-linux-arm64.tar.gz | |
| chmod +x go-getter-file-linux-arm64 | |
| sudo mv go-getter-file-linux-arm64 /usr/local/bin/go-getter-file | |
| ``` | |
| ### macOS | |
| ```bash | |
| # Intel (AMD64) | |
| wget https://github.com/${{ github.repository }}/releases/download/${{ steps.release_type.outputs.tag }}/go-getter-file-${{ steps.release_type.outputs.tag }}-darwin-amd64.tar.gz | |
| tar xzf go-getter-file-${{ steps.release_type.outputs.tag }}-darwin-amd64.tar.gz | |
| chmod +x go-getter-file-darwin-amd64 | |
| sudo mv go-getter-file-darwin-amd64 /usr/local/bin/go-getter-file | |
| # Apple Silicon (ARM64) | |
| wget https://github.com/${{ github.repository }}/releases/download/${{ steps.release_type.outputs.tag }}/go-getter-file-${{ steps.release_type.outputs.tag }}-darwin-arm64.tar.gz | |
| tar xzf go-getter-file-${{ steps.release_type.outputs.tag }}-darwin-arm64.tar.gz | |
| chmod +x go-getter-file-darwin-arm64 | |
| sudo mv go-getter-file-darwin-arm64 /usr/local/bin/go-getter-file | |
| ``` | |
| ### Windows | |
| Download the ZIP file, extract it, and add the executable to your PATH. | |
| ### Verify checksums | |
| ```bash | |
| wget https://github.com/${{ github.repository }}/releases/download/${{ steps.release_type.outputs.tag }}/checksums.txt | |
| sha256sum -c checksums.txt | |
| ``` | |
| ## What's Changed | |
| See the full changelog below. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |