Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(repo): add automated dev releases #14

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/actions/publish-npm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 'Publish to NPM'
description: 'Publish the package to the NPM registry'
inputs:
version:
description: 'The type of version to release.'
tag:
description: 'The tag to publish to on NPM.'
token:
description: 'The NPM authentication token required to publish.'
runs:
using: 'composite'
steps:
# Log the input from GitHub Actions for easy traceability
- name: Log Inputs
run: |
echo "Version: ${{ inputs.version }}"
echo "Tag: ${{ inputs.tag }}"
shell: bash

- name: Checkout Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Get Core Dependencies
uses: ./.github/workflows/actions/get-core-dependencies

- name: Download Build Archive
uses: ./.github/workflows/actions/download-archive
with:
name: stencil-playwright
path: .
filename: stencil-playwright-build.zip

# Remove the ZIP file after we've extracted it - we don't want this committed back to the repo
- name: Delete The Archive ZIP File
run: rm stencil-playwright-build.zip
shell: bash

- name: Bump Version
run: npm version --no-git-tag-version ${{ inputs.version }}
shell: bash

# Log the git diff for easy debugging
- name: Log Generated Changes
run: git --no-pager diff
shell: bash

# Log the git status for easy debugging
- name: Log Status
run: git status
shell: bash

- name: Prepare NPM Token
run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
shell: bash
env:
NPM_TOKEN: ${{ inputs.token }}

# TODO(STENCIL-1206): Add --provenance flag to the command after we've made the repo public
# https://github.blog/changelog/2023-07-26-publishing-with-npm-provenance-from-private-source-repositories-is-no-longer-supported/
- name: Publish to NPM
run: npm publish --tag ${{ inputs.tag }}
shell: bash
53 changes: 53 additions & 0 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 'Dev Release'

on:
workflow_dispatch:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

jobs:
build_stencil_playwright:
name: Build
uses: ./.github/workflows/build.yml

get_dev_version:
name: Get Dev Build Version
runs-on: ubuntu-latest
outputs:
dev-version: ${{ steps.generate-dev-version.outputs.DEV_VERSION }}
steps:
- name: Checkout Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Generate Dev Version
id: generate-dev-version
run: |
PKG_JSON_VERSION=$(cat package.json | jq -r '.version')
GIT_HASH=$(git rev-parse --short HEAD)

# A unique string to publish Stencil Playwright under
# e.g. "2.1.0-dev.1677185104.7c87e34"
DEV_VERSION=$PKG_JSON_VERSION-dev.$(date +"%s").$GIT_HASH

echo "Using version $DEV_VERSION"

# store a key/value pair in GITHUB_OUTPUT
# e.g. "DEV_VERSION=2.1.0-dev.1677185104.7c87e34"
echo "DEV_VERSION=$DEV_VERSION" >> $GITHUB_OUTPUT
shell: bash

release_stencil_playwright:
name: Publish Dev Build
needs: [build_stencil_playwright, get_dev_version]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: ./.github/workflows/actions/publish-npm
with:
tag: dev
version: ${{ needs.get_dev_version.outputs.dev-version }}
token: ${{ secrets.NPM_TOKEN }}
34 changes: 34 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Releasing Stencil Playwright

## Development Releases

Development Releases (or "Dev Releases", "Dev Builds") are installable instances of Stencil Playwright that are:
- Published to the npm registry for distribution within and outside the Stencil team
- Built using the same infrastructure as production releases, with less safety checks
- Used to verify a fix or change to the project prior to a production release

### How to Publish

Only members of the Stencil team may create dev builds of Stencil Playwright.
To publish the package:
1. Navigate to the [Stencil Playwright Dev Release GitHub Action](https://github.com/ionic-team/stencil-playwright/actions/workflows/release-dev.yml) in your browser.
2. Select the 'Run Workflow' dropdown on the right hand side of the page
3. The dropdown will ask you for a branch name to publish from. Any branch may be used here.
4. Select 'Run Workflow'
5. Allow the workflow to run. Upon completion, the output of the 'publish-npm' action will report the published version string.

Following a successful run of the workflow, the package can be installed from the npm registry like any other package.

### Publish Format

Dev Builds are published to the NPM registry under the `@stencil/playwright` scope.
Unlike production builds, dev builds use a specially formatted version string to express its origins.
Dev builds follow the format `BASE_VERSION-dev.EPOCH_DATE.SHA`, where:
- `BASE_VERSION` is the latest production release changes to the build were based off of
- `EPOCH_DATE` is the number of seconds since January 1st, 1970 in UTC
- `SHA` is the git short SHA of the commit used in the release

As an example: `2.1.0-dev.1677185104.7c87e34` was built:
- With v2.1.0 as the latest production build at the time of the dev build
- On Fri, 26 Jan 2024 13:48:17 UTC
- With the commit `7c87e34`