Merge branch 'main' of https://github.com/WhiteElephant-abc/datapack #26
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: | |
| release: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: write | |
| discussions: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract project and version from tag | |
| id: extract_tag | |
| run: | | |
| TAG_NAME="${{ github.ref_name }}" | |
| echo "Tag name: $TAG_NAME" | |
| # Extract project name (everything before _v) | |
| PROJECT_NAME=$(echo "$TAG_NAME" | sed 's/_v.*//') | |
| echo "Project name: $PROJECT_NAME" | |
| # Extract version (everything after _v) | |
| VERSION=$(echo "$TAG_NAME" | sed 's/.*_v//') | |
| echo "Version: $VERSION" | |
| echo "project_name=$PROJECT_NAME" >> $GITHUB_OUTPUT | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Read release notes from NEWS.md | |
| id: release_notes | |
| run: | | |
| NEWS_FILE="${{ steps.extract_tag.outputs.project_name }}/NEWS.md" | |
| if [ -f "$NEWS_FILE" ]; then | |
| echo "Found NEWS.md file: $NEWS_FILE" | |
| RELEASE_BODY=$(cat "$NEWS_FILE") | |
| echo "release_body<<EOF" >> $GITHUB_OUTPUT | |
| echo "$RELEASE_BODY" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| else | |
| echo "NEWS.md not found, using default release notes" | |
| echo "release_body=Release ${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Bazel | |
| uses: bazel-contrib/setup-bazel@0.14.0 | |
| with: | |
| bazelisk-cache: true | |
| disk-cache: ${{ github.workflow }} | |
| repository-cache: true | |
| - name: Build specific project | |
| run: | | |
| bazel build \ | |
| --verbose_failures \ | |
| //${{ steps.extract_tag.outputs.project_name }} | |
| - name: Find and rename build artifact | |
| id: find_artifact | |
| run: | | |
| # Get bazel-bin path | |
| BAZEL_BIN_PATH=$(bazel info bazel-bin) | |
| # Find the built zip file | |
| OLD_ARTIFACT_PATH=$(find $BAZEL_BIN_PATH/${{ steps.extract_tag.outputs.project_name }} -name "*.zip" | head -1) | |
| if [ -z "$OLD_ARTIFACT_PATH" ]; then | |
| echo "Error: No zip file found for project ${{ steps.extract_tag.outputs.project_name }}" | |
| exit 1 | |
| fi | |
| echo "Found artifact: $OLD_ARTIFACT_PATH" | |
| NEW_ARTIFACT_NAME="${{ github.ref_name }}.zip" | |
| mv "$OLD_ARTIFACT_PATH" "$NEW_ARTIFACT_NAME" | |
| echo "Renamed artifact to $NEW_ARTIFACT_NAME" | |
| echo "artifact_path=$NEW_ARTIFACT_NAME" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: ${{ github.ref_name }} | |
| body: ${{ steps.release_notes.outputs.release_body }} | |
| files: ${{ steps.find_artifact.outputs.artifact_path }} | |
| draft: false | |
| prerelease: false | |
| discussion_category_name: Announcements |