|
| 1 | +name: Publish Packages |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +concurrency: version-or-publish-${{ github.ref }} |
| 7 | + |
| 8 | +jobs: |
| 9 | + publish: |
| 10 | + name: Publish Packages |
| 11 | + permissions: |
| 12 | + contents: write |
| 13 | + pull-requests: write |
| 14 | + runs-on: ubuntu-latest |
| 15 | + environment: publish |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 18 | + with: |
| 19 | + fetch-depth: 0 # To get all tags |
| 20 | + ref: ${{ github.ref }} |
| 21 | + - name: Set up environment |
| 22 | + uses: ./.github/actions/setup |
| 23 | + - name: Install Foundry |
| 24 | + uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1.4.0 |
| 25 | + - name: Create Prepare Release PR or Publish |
| 26 | + id: changesets |
| 27 | + uses: changesets/action@001cd79f0a536e733315164543a727bdf2d70aff # v1.5.1 |
| 28 | + with: |
| 29 | + title: Prepare Release |
| 30 | + commit: Prepare Release |
| 31 | + version: npm run version-package |
| 32 | + publish: npm run publish-package |
| 33 | + commitMode: github-api |
| 34 | + env: |
| 35 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 37 | + - name: Check changesets status |
| 38 | + if: steps.changesets.outputs.hasChangesets == 'true' |
| 39 | + run: | |
| 40 | + echo "Changesets found. Merge Prepare Release PR before publishing." |
| 41 | + exit 1 |
| 42 | + - name: Check publish status |
| 43 | + if: steps.changesets.outputs.published == 'false' |
| 44 | + run: | |
| 45 | + echo "Publish failed. Check the logs for more details." |
| 46 | + exit 1 |
| 47 | + - name: Publish to Soldeer |
| 48 | + if: steps.changesets.outputs.published == 'true' |
| 49 | + run: | |
| 50 | + mkdir -p ~/.soldeer |
| 51 | + echo "$SOLDEER_TOKEN" > ~/.soldeer/.soldeer_login |
| 52 | + PACKAGE_VERSION=$(jq -r .version package.json) |
| 53 | + echo "Publishing version $PACKAGE_VERSION to Soldeer..." |
| 54 | + forge soldeer push openzeppelin-foundry-upgrades~$PACKAGE_VERSION |
| 55 | + shell: bash |
| 56 | + env: |
| 57 | + SOLDEER_TOKEN: ${{ secrets.SOLDEER_TOKEN }} |
0 commit comments