name: Release on: push: branches: [main] # Never let two releases run at once: the second would publish against a # version the first has already taken. concurrency: group: release cancel-in-progress: false permissions: contents: write pull-requests: write # Required for npm trusted publishing: the job mints a short-lived OIDC # token instead of using a stored npm credential. id-token: write jobs: release: name: Version or publish runs-on: ubuntu-latest steps: - name: Checkout Dropzone uses: actions/checkout@v7 with: fetch-depth: 0 - name: Setup pnpm uses: pnpm/action-setup@v6 - name: Setup Node.js uses: actions/setup-node@v7 with: node-version: 22 cache: pnpm registry-url: "https://registry.npmjs.org" - run: pnpm install --frozen-lockfile # dist/ is not committed, so it has to be built before anything is # published. package.json also runs this via prepublishOnly. - run: pnpm build:lib # With changesets pending, this opens (or updates) a "Version packages" # pull request. When that pull request is merged there are no changesets # left, so this publishes instead. # # v2 is required: v1 predates Changesets v3 and cannot read its publish # output, so it silently reports nothing as published and skips pushing # tags and creating releases. No npm credential is set here on purpose -- # with id-token: write and a trusted publisher on npmjs.com, pnpm # authenticates over OIDC, and an empty NODE_AUTH_TOKEN would break that # (see pnpm#11513). - name: Create version pull request or publish id: changesets uses: changesets/action@v2 with: version-script: pnpm changeset:version publish-script: pnpm changeset:publish pr-title: "Version packages" commit-message: "Version packages" github-token: ${{ secrets.GITHUB_TOKEN }} # The releases have always carried a dist.zip, and the changelog links to # it directly, so keep publishing one. # # The tag is @, not v. Changesets only uses the # v prefix for a single-package repository -- see buildGitTag in # @changesets/cli, which switches on the workspace tool -- so the move to # a monorepo changed the scheme, and v6.2.1 was looked up against a # release that had never been created. - name: Attach dist.zip to the release if: steps.changesets.outputs.published == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Bracket notation: a hyphenated output name would otherwise parse as # a subtraction in an Actions expression. TAG: ${{ fromJSON(steps.changesets.outputs['published-packages'])[0].name }}@${{ fromJSON(steps.changesets.outputs['published-packages'])[0].version }} run: | cd packages/dropzone zip -r dist.zip dist gh release upload "$TAG" dist.zip --clobber # dropzone-packagist rebuilds itself from the release above. It watches # this repo's releases on a schedule rather than being pushed to, so no # cross-repo credential is needed here. # # The bower dispatch was dropped: bower has been deprecated since 2017 # and dropzone-bower has not been touched since 2021.