Build-Release #5
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: Build-Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "tag: git tag you want create. (sample 1.0.0)" | |
| required: true | |
| dry-run: | |
| description: "dry-run: true will never create relase/nuget." | |
| required: true | |
| default: false | |
| type: boolean | |
| jobs: | |
| build-and-push-rust: | |
| permissions: | |
| contents: write | |
| id-token: write # required for crates.io publish | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: Cysharp/Actions/.github/actions/checkout@main | |
| - uses: rust-lang/crates-io-auth-action@b7e9a28eded4986ec6b1fa40eeee8f8f165559ec # v1.0.3 | |
| id: auth | |
| - run: cargo build --verbose | |
| - run: cargo test update_package_version -- ${{ inputs.tag }} --nocapture | |
| - run: | | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git commit -m "Update cargo.toml version to ${{ inputs.tag }}" -a | |
| - run: cargo publish --manifest-path csbindgen/Cargo.toml | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} | |
| - run: git tag ${{ inputs.tag }} | |
| - name: Push changes | |
| uses: ad-m/github-push-action@77c5b412c50b723d2a4fbc6d71fb5723bcd439aa | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: ${{ github.ref }} | |
| tags: true | |
| build-dotnet: | |
| needs: [build-and-push-rust] | |
| permissions: | |
| contents: read | |
| id-token: write # required for NuGet Trusted Publish | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Load secrets | |
| id: op-load-secret | |
| uses: 1password/load-secrets-action@13f58eec611f8e5db52ec16247f58c508398f3e6 # v3.0.0 | |
| with: | |
| export-env: false | |
| env: | |
| OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN_PUBLIC }} | |
| NUGET_KEY: "op://${{ vars.OP_VAULT_ACTIONS_PUBLIC }}/NUGET_KEY/credential" | |
| - uses: Cysharp/Actions/.github/actions/checkout@main | |
| - uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
| # pack nuget | |
| - run: dotnet build -c Release -p:Version=${{ inputs.tag }} | |
| - run: dotnet pack -c Release --no-build -p:Version=${{ inputs.tag }} -o ./publish | |
| - uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
| with: | |
| name: nuget | |
| path: ./publish | |
| retention-days: 1 | |
| # push nuget | |
| - name: NuGet login (OIDC) | |
| uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0 | |
| id: login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - run: dotnet nuget push "./publish/*.nupkg" --skip-duplicate -s https://api.nuget.org/v3/index.json -k "${NUGET_KEY}" | |
| if: ${{ !inputs.dry-run }} | |
| env: | |
| NUGET_KEY: ${{ steps.login.outputs.NUGET_API_KEY }} | |
| create-release: | |
| needs: [build-dotnet, build-and-push-rust] | |
| permissions: | |
| contents: write | |
| id-token: write # required for NuGet Trusted Publish | |
| uses: Cysharp/Actions/.github/workflows/create-release.yaml@main | |
| with: | |
| commit-id: "" | |
| dry-run: ${{ inputs.dry-run }} | |
| tag: ${{ inputs.tag }} | |
| nuget-push: false | |
| release-upload: false | |
| secrets: inherit |