new build pipeline test #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*.*.*' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Verify tag is on main branch | |
| run: | | |
| # Get the commit SHA of the tag | |
| TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref }}) | |
| # Get the commit SHA of the main branch | |
| MAIN_COMMIT=$(git rev-parse origin/main) | |
| # Check if the tag points to a commit that is reachable from main | |
| if ! git merge-base --is-ancestor $TAG_COMMIT origin/main; then | |
| echo "Error: Tag ${{ github.ref_name }} is not on the main branch" | |
| exit 1 | |
| fi | |
| # Additionally, verify that main is reachable from the tag (no divergence) | |
| if ! git merge-base --is-ancestor origin/main $TAG_COMMIT; then | |
| echo "Error: Tag ${{ github.ref_name }} is ahead of main but on a different branch" | |
| exit 1 | |
| fi | |
| echo "✓ Tag ${{ github.ref_name }} is on main branch" | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '>= 1.25' | |
| cache: false | |
| - name: Build | |
| run: | | |
| chmod +x build-all.sh | |
| TriggeredTagName=${GITHUB_REF#refs/tags/} | |
| CurrentGitTagName=$(git describe --tags --exact-match 2>/dev/null || echo "not-a-tag") | |
| if [ "$TriggeredTagName" != "$CurrentGitTagName" ]; then | |
| echo "Validation failed: Triggered tag $TriggeredTagName does not match current git state $CurrentGitTagName" | |
| exit 1 | |
| fi | |
| ./build-all.sh "$TriggeredTagName" | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| dist/CHECKSUMS.txt | |
| dist/code2md-linux-amd64 | |
| dist/code2md-linux-arm64 | |
| dist/code2md-darwin-amd64 | |
| dist/code2md-darwin-arm64 | |
| dist/code2md-windows-amd64.exe | |
| dist/code2md-windows-arm64.exe | |
| name: Release ${{ github.ref_name }} | |
| draft: true | |
| prerelease: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |