Code Monkey home page Code Monkey logo

changesets-snapshot-action's Introduction

Changesets Snapshot Release Action

This action for Changesets runs the Snapshot workflow for your repository, based on changes done in Pull Requests.

This action is helpful if you wish to create an automated release flow for changes done in PRs, on in any temporary change.

The following flow is being executed:

  • Check for available changeset files in the PR.
  • Runs version flow with --snapshot provided.
  • Runs user script for build/preparation for the release.
  • Runs publish flow with --tag and --no-git-tag (to create a "temporary" release)
  • Publishes a GitHub comment on the Pull Request, with the list of releases done.

image

This GitHub Action does not create GitHub Releases and does not push Git tags - it meant to be used for canary releases, and encapsulate the changes within a PR.

Usage

Inputs

  • prepareScript - A custom, user-provided script, that is being executed between version and publish scripts. Usually, this is where your build script goes.
  • tag - The git tag to be used with the --snapshot TAG (version command) and --tag TAG (publish command)
  • cwd - Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()
  • setupGitUser - Sets up the git user for commits as "github-actions[bot]". Default to true

Outputs

  • published - A boolean value to indicate whether a publishing is happened or not
  • publishedPackages - A JSON array to present the published packages. The format is [{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]

Example workflow:

Without Publishing

Create a file at .github/workflows/snapshot.yml with the following content.

name: Snapshot

on:
  pull_request: # Run only for PRs
    branches:
      - master
    paths:
      - ".changeset/**/*.md" # this will make sure to run only on PRs that adds Changesets

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    if: github.event.pull_request.head.repo.full_name == github.repository # run only for original, non-fork PRs
    steps:
      - name: Checkout Master
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Use Node
        uses: actions/setup-node@v3
        with:
          node-version: 18

      # this is where you do your regular setup, dependencies installation and so on

      - name: Release Snapshot
        uses: "the-guild-org/[email protected]"
        with:
          tag: alpha
          prepareScript: "yarn build"
        env:
          NPM_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} # NPM Token
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub Token

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.