Update Makefile and GitHub Actions workflow to standardize build time… #2
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*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '1.24' | |
| cache: true | |
| - name: Compute metadata | |
| id: meta | |
| run: | | |
| echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| echo "BUILD_TIME=$(date -u '+%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
| - name: Run tests | |
| run: go test -v ./... | |
| - name: Build binaries (make build-all) | |
| env: | |
| VERSION: ${{ steps.meta.outputs.VERSION }} | |
| COMMIT: ${{ steps.meta.outputs.COMMIT }} | |
| BUILD_TIME: ${{ steps.meta.outputs.BUILD_TIME }} | |
| run: | | |
| make build-all | |
| - name: Create checksums | |
| run: | | |
| cd bin | |
| sha256sum * > checksums.txt | |
| cat checksums.txt | |
| - name: Create archives | |
| run: | | |
| cd bin | |
| # Create tar.gz for Unix systems | |
| for file in vulhub-linux-* vulhub-darwin-*; do | |
| tar -czvf "${file}.tar.gz" "$file" | |
| rm "$file" | |
| done | |
| # Create zip for Windows | |
| for file in vulhub-windows-*.exe; do | |
| zip "${file%.exe}.zip" "$file" | |
| rm "$file" | |
| done | |
| # Regenerate checksums for archives | |
| sha256sum *.tar.gz *.zip > checksums.txt | |
| cat checksums.txt | |
| - name: Generate changelog | |
| id: changelog | |
| run: | | |
| # Get the previous tag | |
| PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| if [ -n "$PREV_TAG" ]; then | |
| echo "Generating changelog from $PREV_TAG to ${{ steps.meta.outputs.VERSION }}" | |
| CHANGELOG=$(git log --pretty=format:"- %s (%h)" ${PREV_TAG}..HEAD) | |
| else | |
| echo "No previous tag found, using all commits" | |
| CHANGELOG=$(git log --pretty=format:"- %s (%h)") | |
| fi | |
| # Write to file to handle multiline | |
| echo "$CHANGELOG" > changelog.txt | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: ${{ steps.meta.outputs.VERSION }} | |
| body_path: changelog.txt | |
| draft: true | |
| prerelease: ${{ contains(steps.meta.outputs.VERSION, '-') }} | |
| files: | | |
| bin/*.tar.gz | |
| bin/*.zip | |
| bin/checksums.txt |