Merge pull request #100 from sonesuke/chore/release-v0.3.0-final-polish #7
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: | |
| check-branch: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| on_main: ${{ steps.check.outputs.on_main }} | |
| steps: | |
| - name: Set git default branch | |
| run: | | |
| git config --global init.defaultBranch main | |
| git config --global advice.detachedHead false | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - id: check | |
| run: | | |
| # Check if the tag is reachable from the main branch | |
| if git branch -r --contains ${{ github.ref_name }} | grep -q 'origin/main'; then | |
| echo "on_main=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "on_main=false" >> $GITHUB_OUTPUT | |
| fi | |
| build-rust: | |
| needs: check-branch | |
| if: needs.check-branch.outputs.on_main == 'true' | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| target: x86_64-unknown-linux-gnu | |
| artifact_name: docgraph | |
| asset_name: docgraph-x86_64-unknown-linux-gnu.tar.gz | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| artifact_name: docgraph | |
| asset_name: docgraph-x86_64-apple-darwin.tar.gz | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| artifact_name: docgraph | |
| asset_name: docgraph-aarch64-apple-darwin.tar.gz | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact_name: docgraph.exe | |
| asset_name: docgraph-x86_64-pc-windows-msvc.zip | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Set git default branch | |
| run: | | |
| git config --global init.defaultBranch main | |
| git config --global advice.detachedHead false | |
| - uses: actions/checkout@v6 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Build | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package (Unix) | |
| if: runner.os != 'Windows' | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| tar -czf ../../../${{ matrix.asset_name }} ${{ matrix.artifact_name }} | |
| - name: Package (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| Compress-Archive -Path ${{ matrix.artifact_name }} -DestinationPath ../../../${{ matrix.asset_name }} | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.asset_name }} | |
| path: ${{ matrix.asset_name }} | |
| build-vsix: | |
| needs: check-branch | |
| if: needs.check-branch.outputs.on_main == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set git default branch | |
| run: | | |
| git config --global init.defaultBranch main | |
| git config --global advice.detachedHead false | |
| - uses: actions/checkout@v6 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install Dependencies | |
| run: cd vsix && npm install | |
| - name: Package VSIX | |
| run: | | |
| cd vsix | |
| npx vsce package -o ../docgraph.vsix | |
| - name: Upload VSIX | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: docgraph.vsix | |
| path: docgraph.vsix | |
| create-release: | |
| needs: [build-rust, build-vsix] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set git default branch | |
| run: | | |
| git config --global init.defaultBranch main | |
| git config --global advice.detachedHead false | |
| - uses: actions/checkout@v6 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Generate Release Notes | |
| uses: orhun/git-cliff-action@v4 | |
| with: | |
| config: cliff.toml | |
| args: --latest --strip header | |
| env: | |
| OUTPUT: RELEASE_NOTES.md | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| artifacts/*.tar.gz | |
| artifacts/*.zip | |
| artifacts/*.vsix | |
| body_path: RELEASE_NOTES.md | |
| generate_release_notes: false | |
| draft: false | |
| prerelease: false |