Skip to content

Commit 99008b4

Browse files
authored
chore(ci): add automated dev releases (#467)
this commit implements an initial workflow for dev releases for stencil sass. it is capable of: - generating a build based using the same logic as other ci workflows - generating a dev build version - invoking a publish action with the dev version & 'dev' tag a new publish action is added that is capable of incrementing the version of the package and publishing changes to npm has been added. the intent is to reuse this in some capacity for production releases. this commit also includes additional actions for building the project & downloading/uploading archives. to date, ci has been rather simplistic in this repo. however, it's planned to integrate these actions into existing workflows once this has been added to `main`.
1 parent 75b8253 commit 99008b4

File tree

7 files changed

+240
-0
lines changed

7 files changed

+240
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 'Create Stencil Sass Archive Download'
2+
description: 'downloads and decompresses an archive from a previous job'
3+
inputs:
4+
path:
5+
description: 'location to decompress the archive to'
6+
filename:
7+
description: 'the name of the decompressed artifact'
8+
name:
9+
description: 'name of the archive to decompress'
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
14+
with:
15+
name: ${{ inputs.name }}
16+
path: ${{ inputs.path }}
17+
18+
- name: Extract Archive
19+
run: unzip -q -o ${{ inputs.path }}/${{ inputs.filename }}
20+
shell: bash
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: 'Get Core Dependencies'
2+
description: 'sets the node version & initializes core dependencies'
3+
runs:
4+
using: composite
5+
steps:
6+
# this overrides previous versions of the node runtime that was set.
7+
# jobs that need a different version of the Node runtime should explicitly
8+
# set their node version after running this step
9+
- name: Use Node Version from Volta
10+
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
11+
with:
12+
node-version-file: './package.json'
13+
cache: 'npm'
14+
15+
- name: Install Dependencies
16+
run: npm ci
17+
shell: bash
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: 'Publish to NPM'
2+
description: 'Publish the package to the NPM registry'
3+
inputs:
4+
version:
5+
description: 'The type of version to release.'
6+
tag:
7+
description: 'The tag to publish to on NPM.'
8+
token:
9+
description: 'The NPM authentication token required to publish.'
10+
runs:
11+
using: 'composite'
12+
steps:
13+
# Log the input from GitHub Actions for easy traceability
14+
- name: Log Inputs
15+
run: |
16+
echo "Version: ${{ inputs.version }}"
17+
echo "Tag: ${{ inputs.tag }}"
18+
shell: bash
19+
20+
- name: Checkout Code
21+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
22+
23+
- name: Get Core Dependencies
24+
uses: ./.github/workflows/actions/get-core-dependencies
25+
26+
- name: Download Build Archive
27+
uses: ./.github/workflows/actions/download-archive
28+
with:
29+
name: stencil-sass
30+
path: .
31+
filename: stencil-sass-build.zip
32+
33+
# Remove the ZIP file after we've extracted it - we don't want this committed back to the repo
34+
- name: Delete The Archive ZIP File
35+
run: rm stencil-sass-build.zip
36+
shell: bash
37+
38+
- name: Bump Version
39+
run: npm version --no-git-tag-version ${{ inputs.version }}
40+
shell: bash
41+
42+
# Log the git diff for easy debugging
43+
- name: Log Generated Changes
44+
run: git --no-pager diff
45+
shell: bash
46+
47+
# Log the git status for easy debugging
48+
- name: Log Status
49+
run: git status
50+
shell: bash
51+
52+
- name: Prepare NPM Token
53+
run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
54+
shell: bash
55+
env:
56+
NPM_TOKEN: ${{ inputs.token }}
57+
58+
- name: Publish to NPM
59+
run: npm publish --tag ${{ inputs.tag }} --provenance
60+
shell: bash
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 'Create Stencil Sass Archive Upload'
2+
description: 'compresses and uploads an archive to be reused across jobs'
3+
inputs:
4+
paths:
5+
description: 'paths to files or directories to archive (recursive)'
6+
output:
7+
description: 'output file name'
8+
name:
9+
description: 'name of the archive to upload'
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- name: Create Archive
14+
run: zip -q -r ${{ inputs.output }} ${{ inputs.paths }}
15+
shell: bash
16+
17+
- uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4.2.0
18+
with:
19+
name: ${{ inputs.name }}
20+
path: ${{ inputs.output }}

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build Stencil Sass
2+
3+
on:
4+
workflow_call:
5+
# Make this a reusable workflow, no value needed
6+
# https://docs.github.com/en/actions/using-workflows/reusing-workflows
7+
8+
jobs:
9+
build_stencil_sass:
10+
name: Build Stencil Sass
11+
runs-on: 'ubuntu-latest'
12+
steps:
13+
- name: Checkout Code
14+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
15+
with:
16+
# the pull_request_target event will consider the HEAD of `main` to be the SHA to use.
17+
# attempt to use the SHA associated with a pull request and fallback to HEAD of `main`
18+
ref: ${{ github.event_name == 'pull_request_target' && format('refs/pull/{0}/merge', github.event.number) || '' }}
19+
persist-credentials: false
20+
21+
- name: Get Core Dependencies
22+
uses: ./.github/workflows/actions/get-core-dependencies
23+
24+
- name: Stencil Sass Build
25+
run: npm run build
26+
shell: bash
27+
28+
- name: Unit Tests
29+
run: npm test
30+
shell: bash
31+
32+
- name: Upload Build Artifacts
33+
uses: ./.github/workflows/actions/upload-archive
34+
with:
35+
name: stencil-sass
36+
output: stencil-sass-build.zip
37+
paths: ./dist/

.github/workflows/release-dev.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: 'Dev Release'
2+
3+
on:
4+
workflow_dispatch:
5+
# Make this a reusable workflow, no value needed
6+
# https://docs.github.com/en/actions/using-workflows/reusing-workflows
7+
8+
jobs:
9+
build_stencil_sass:
10+
name: Build
11+
uses: ./.github/workflows/build.yml
12+
13+
get_dev_version:
14+
name: Get Dev Build Version
15+
runs-on: ubuntu-latest
16+
outputs:
17+
dev-version: ${{ steps.generate-dev-version.outputs.DEV_VERSION }}
18+
steps:
19+
- name: Checkout Code
20+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
21+
22+
- name: Generate Dev Version
23+
id: generate-dev-version
24+
run: |
25+
PKG_JSON_VERSION=$(cat package.json | jq -r '.version')
26+
GIT_HASH=$(git rev-parse --short HEAD)
27+
28+
# A unique string to publish Stencil Sass under
29+
# e.g. "2.1.0-dev.1677185104.7c87e34"
30+
DEV_VERSION=$PKG_JSON_VERSION-dev.$(date +"%s").$GIT_HASH
31+
32+
echo "Using version $DEV_VERSION"
33+
34+
# store a key/value pair in GITHUB_OUTPUT
35+
# e.g. "DEV_VERSION=2.1.0-dev.1677185104.7c87e34"
36+
echo "DEV_VERSION=$DEV_VERSION" >> $GITHUB_OUTPUT
37+
shell: bash
38+
39+
release_sass_stencil:
40+
name: Publish Dev Build
41+
needs: [build_stencil_sass, get_dev_version]
42+
runs-on: ubuntu-latest
43+
permissions:
44+
id-token: write
45+
steps:
46+
- name: Checkout Code
47+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
48+
- uses: ./.github/workflows/actions/publish-npm
49+
with:
50+
tag: dev
51+
version: ${{ needs.get_dev_version.outputs.dev-version }}
52+
token: ${{ secrets.NPM_TOKEN }}

RELEASE.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Releasing Stencil Sass
2+
3+
## Development Releases
4+
5+
Development Releases (or "Dev Releases", "Dev Builds") are installable instances of Stencil Sass that are:
6+
- Published to the npm registry for distribution within and outside the Stencil team
7+
- Built using the same infrastructure as production releases, with less safety checks
8+
- Used to verify a fix or change to the project prior to a production release
9+
10+
### How to Publish
11+
12+
Only members of the Stencil team may create dev builds of Stencil Sass.
13+
To publish the package:
14+
1. Navigate to the [Stencil Sass Dev Release GitHub Action](https://github.com/ionic-team/stencil-sass/actions/workflows/release-dev.yml) in your browser.
15+
2. Select the 'Run Workflow' dropdown on the right hand side of the page
16+
3. The dropdown will ask you for a branch name to publish from. Any branch may be used here.
17+
4. Select 'Run Workflow'
18+
5. Allow the workflow to run. Upon completion, the output of the 'publish-npm' action will report the published version string.
19+
20+
Following a successful run of the workflow, the package can be installed from the npm registry like any other package.
21+
22+
### Publish Format
23+
24+
Dev Builds are published to the NPM registry under the `@stencil/sass` scope.
25+
Unlike production builds, dev builds use a specially formatted version string to express its origins.
26+
Dev builds follow the format `BASE_VERSION-dev.EPOCH_DATE.SHA`, where:
27+
- `BASE_VERSION` is the latest production release changes to the build were based off of
28+
- `EPOCH_DATE` is the number of seconds since January 1st, 1970 in UTC
29+
- `SHA` is the git short SHA of the commit used in the release
30+
31+
As an example: `2.1.0-dev.1677185104.7c87e34` was built:
32+
- With v2.1.0 as the latest production build at the time of the dev build
33+
- On Fri, 26 Jan 2024 13:48:17 UTC
34+
- With the commit `7c87e34`

0 commit comments

Comments
 (0)