publish: BYK/opencode-lore@0.4.2 #28
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: Publish | |
| on: | |
| issues: | |
| types: [labeled] | |
| jobs: | |
| publish: | |
| if: github.event.label.name == 'accepted' && github.event.issue.state == 'open' | |
| runs-on: ubuntu-latest | |
| name: Publish release | |
| environment: production | |
| permissions: | |
| contents: write | |
| id-token: write | |
| issues: write | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/create-github-app-token@v1 | |
| id: app-token | |
| with: | |
| app-id: ${{ vars.APP_ID }} | |
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
| - name: Parse publish request | |
| id: inputs | |
| env: | |
| ISSUE_TITLE: ${{ github.event.issue.title }} | |
| run: | | |
| # Title format: "publish: owner/repo@VERSION" | |
| VERSION=$(echo "$ISSUE_TITLE" | grep -oP '@\K[^\s]+$') | |
| if [[ -z "$VERSION" ]]; then | |
| echo "::error::Could not parse version from issue title: $ISSUE_TITLE" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: release/${{ steps.inputs.outputs.version }} | |
| token: ${{ steps.app-token.outputs.token }} | |
| fetch-depth: 0 | |
| - name: Set git user | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Upgrade npm for OIDC trusted publishing | |
| run: | | |
| npm install -g npm@latest | |
| npm --version | |
| - name: Install Craft | |
| run: | | |
| CRAFT_URL=$(curl -fsSL https://api.github.com/repos/getsentry/craft/releases/latest \ | |
| | jq -r '.assets[] | select(.name == "craft") | .browser_download_url') | |
| sudo curl -fsSL -o /usr/local/bin/craft "$CRAFT_URL" | |
| sudo chmod +x /usr/local/bin/craft | |
| - name: Publish | |
| run: craft publish "${{ steps.inputs.outputs.version }}" --no-input --no-status-check | |
| env: | |
| GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
| - name: Close issue on success | |
| if: success() | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh issue close "${{ github.event.issue.number }}" \ | |
| --comment "Published **${{ steps.inputs.outputs.version }}** successfully. | |
| [Workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" | |
| - name: Comment on failure | |
| if: failure() | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh issue comment "${{ github.event.issue.number }}" \ | |
| --body "Publish failed. [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" | |
| gh issue edit "${{ github.event.issue.number }}" --remove-label accepted |