diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml new file mode 100644 index 00000000..c989e6ce --- /dev/null +++ b/.github/workflows/promote.yml @@ -0,0 +1,31 @@ +name: Promote to latest + +on: + workflow_dispatch: + inputs: + version: + description: "Version to promote (e.g. 2.18.0). Leave empty to use version from package.json." + required: false + type: string + +jobs: + promote: + name: Promote npm dist-tag to latest + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-bun + + - name: Configure npm auth + run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Promote to latest + run: | + if [ -n "${{ inputs.version }}" ]; then + bun run promote:latest "${{ inputs.version }}" + else + bun run promote:latest + fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..3aaa7465 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,64 @@ +name: Release + +on: + push: + tags: + - "v*" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +permissions: + contents: write + +jobs: + publish: + name: Publish to npm + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-bun + + - name: Build + run: bun run build + + - name: Configure npm auth + run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish to npm (next) + run: bun run publish:next + + github-release: + name: Create GitHub Release + runs-on: ubuntu-latest + needs: publish + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Generate release notes + id: notes + run: | + # Get the previous tag + PREV_TAG=$(git tag --sort=-version:refname | grep -v "$(git describe --tags --exact-match)" | head -1) + if [ -z "$PREV_TAG" ]; then + echo "body=Initial release" >> "$GITHUB_OUTPUT" + else + NOTES=$(git log --pretty=format:"- %s" "${PREV_TAG}..HEAD" --no-merges) + { + echo "body<> "$GITHUB_OUTPUT" + fi + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + body: ${{ steps.notes.outputs.body }} + generate_release_notes: true