name: Create Release on Tag on: push: tags: - "Release_*" permissions: contents: write jobs: # First run tests test: runs-on: ubuntu-latest steps: - name: Setup Go uses: actions/setup-go@v5 with: go-version: "1.23" - name: Checkout obitools4 project uses: actions/checkout@v4 - name: Run tests run: make githubtests # Build binaries for each platform build: needs: test strategy: matrix: include: - os: ubuntu-latest goos: linux goarch: amd64 output_name: linux_amd64 - os: ubuntu-latest goos: linux goarch: arm64 output_name: linux_arm64 cross_compile: true - os: macos-latest goos: darwin goarch: amd64 output_name: darwin_amd64 - os: macos-latest goos: darwin goarch: arm64 output_name: darwin_arm64 runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 with: go-version: "1.23" - name: Extract version from tag id: get_version run: | TAG=${GITHUB_REF#refs/tags/Release_} echo "version=$TAG" >> $GITHUB_OUTPUT - name: Install cross-compilation tools (Linux ARM64 only) if: matrix.cross_compile run: | sudo apt-get update sudo apt-get install -y gcc-aarch64-linux-gnu - name: Build binaries env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} CC: ${{ matrix.cross_compile && 'aarch64-linux-gnu-gcc' || '' }} VERSION: ${{ steps.get_version.outputs.version }} run: | make obitools mkdir -p artifacts cd build for binary in *; do tar -czf ../artifacts/${binary}_${VERSION}_${{ matrix.output_name }}.tar.gz ${binary} done - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: binaries-${{ matrix.output_name }} path: artifacts/* # Create the release create-release: needs: build runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Extract version from tag id: get_version run: | TAG=${GITHUB_REF#refs/tags/Release_} echo "version=$TAG" >> $GITHUB_OUTPUT - name: Download all artifacts uses: actions/download-artifact@v4 with: path: release-artifacts - name: Prepare release directory run: | mkdir -p release find release-artifacts -type f -name "*.tar.gz" -exec cp {} release/ \; ls -lh release/ - name: Generate Release Notes env: VERSION: ${{ steps.get_version.outputs.version }} run: | PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") echo "# OBITools4 Release ${VERSION}" > release_notes.md echo "" >> release_notes.md if [ -n "$PREV_TAG" ]; then echo "## Changes since ${PREV_TAG}" >> release_notes.md echo "" >> release_notes.md git log ${PREV_TAG}..HEAD --pretty=format:"- %s" >> release_notes.md else echo "## Changes" >> release_notes.md echo "" >> release_notes.md git log --pretty=format:"- %s" -n 20 >> release_notes.md fi echo "" >> release_notes.md echo "" >> release_notes.md echo "## Installation" >> release_notes.md echo "" >> release_notes.md echo "Download the appropriate binary for your system and extract it:" >> release_notes.md echo "" >> release_notes.md echo "### Linux (AMD64)" >> release_notes.md echo '```bash' >> release_notes.md echo "tar -xzf _${VERSION}_linux_amd64.tar.gz" >> release_notes.md echo '```' >> release_notes.md echo "" >> release_notes.md echo "### Linux (ARM64)" >> release_notes.md echo '```bash' >> release_notes.md echo "tar -xzf _${VERSION}_linux_arm64.tar.gz" >> release_notes.md echo '```' >> release_notes.md echo "" >> release_notes.md echo "### macOS (Intel)" >> release_notes.md echo '```bash' >> release_notes.md echo "tar -xzf _${VERSION}_darwin_amd64.tar.gz" >> release_notes.md echo '```' >> release_notes.md echo "" >> release_notes.md echo "### macOS (Apple Silicon)" >> release_notes.md echo '```bash' >> release_notes.md echo "tar -xzf _${VERSION}_darwin_arm64.tar.gz" >> release_notes.md echo '```' >> release_notes.md echo "" >> release_notes.md echo "Available tools: Replace \`\` with one of the obitools commands." >> release_notes.md - name: Create GitHub Release uses: softprops/action-gh-release@v1 with: name: Release ${{ steps.get_version.outputs.version }} body_path: release_notes.md files: release/* draft: false prerelease: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}