-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix optic release workflow (#50)
* chore: use Node 20 This required updating the npm lockfile and CI. * update lock file * attempt to fix lockfile * fix lockfile again... * try to fix workflow * try something else... * fix type * update node version in release workflow * fix: fix optic release workflow * checkout code first * remove quotes * fix up artifact for release * remove unused steps in build workflow * nit --------- Co-authored-by: Evan Hahn <[email protected]>
- Loading branch information
1 parent
2655d44
commit 8e6c3f2
Showing
2 changed files
with
9 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,14 @@ | ||
# Run whenever code is pushed or when manually triggers from Github UI | ||
# Run whenever code is pushed | ||
on: | ||
push: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: '(Optional) Version name, in format v1.2.3' | ||
required: false | ||
|
||
name: Build & Release | ||
name: Build | ||
|
||
jobs: | ||
prepare-release: | ||
name: Prepare Release | ||
runs-on: ubuntu-20.04 | ||
if: github.event_name == 'workflow_dispatch' | ||
outputs: | ||
version: ${{ steps.pkg.outputs.prop }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Use Node.js 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
- name: Configure git user & email | ||
run: | | ||
git config user.name Github Actions | ||
git config user.email [email protected] | ||
- name: Prepare new version | ||
run: npx standard-version --release-as '${{ github.event.inputs.version }}' | ||
- name: Commit changes | ||
run: git push --follow-tags | ||
- name: Get package version | ||
id: pkg | ||
uses: notiz-dev/github-action-json-property@release | ||
with: | ||
path: 'package.json' | ||
prop_path: 'version' | ||
create-release: | ||
name: Create Release | ||
# Run this job after prepare-release, whether or not it runs, and run on | ||
# either a tag push or when manually triggered | ||
if: always() && (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))) | ||
needs: prepare-release | ||
outputs: | ||
tag: ${{ steps.get_tag.outputs.tag }} | ||
upload_url: ${{ steps.release.outputs.upload_url }} | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Get tag name | ||
id: get_tag | ||
run: | | ||
if [[ -n '${{ needs.prepare-release.outputs.version }}' ]]; then | ||
TAG=v${{ needs.prepare-release.outputs.version }} | ||
else | ||
# Use bash parameter expansion to remove refs/tags/ from GITHUB_REF | ||
TAG=${GITHUB_REF/refs\/tags\//} | ||
fi | ||
echo ::set-output name=tag::$TAG | ||
- name: Create Release | ||
id: release | ||
uses: actions/create-release@v1 | ||
continue-on-error: true # Ignore failure if release already exists | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
tag_name: ${{ steps.get_tag.outputs.tag }} | ||
release_name: Release ${{ steps.get_tag.outputs.tag }} | ||
body: | | ||
For changes see [CHANGELOG.md](CHANGELOG.md) | ||
draft: false | ||
prerelease: false | ||
build: | ||
# This step runs on every push, ensures there is an artifact for each push | ||
name: Build | ||
runs-on: ubuntu-20.04 | ||
if: always() | ||
needs: [prepare-release, create-release] | ||
outputs: | ||
artifact: ${{ steps.filename.outputs.filename }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
@@ -89,13 +19,8 @@ jobs: | |
- name: Get version | ||
id: version | ||
run: | | ||
# Use either the git tag or the git commit sha to identify the version | ||
if [[ -n '${{ needs.create-release.outputs.tag }}' ]]; then | ||
VERSION=${{ needs.create-release.outputs.tag }} | ||
else | ||
# Get a short ID to the commit used to build this version | ||
VERSION=$(git rev-parse --short ${{ github.sha }}) | ||
fi | ||
# Use git commit sha to identify the version | ||
VERSION=$(git rev-parse --short ${{ github.sha }}) | ||
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" | ||
- name: Write version to metadata.json | ||
uses: jossef/[email protected] | ||
|
@@ -117,27 +42,3 @@ jobs: | |
with: | ||
name: ${{ steps.filename.outputs.FILENAME }} | ||
path: build/${{ steps.filename.outputs.FILENAME }} | ||
upload-release: | ||
name: Upload release | ||
runs-on: ubuntu-20.04 | ||
# Only runs if a release has been created | ||
needs: [build, create-release] | ||
steps: | ||
- name: Download artifact | ||
id: download | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ needs.build.outputs.artifact }} | ||
- name: 'Echo download path' | ||
run: echo ${{ steps.download.outputs.download-path }} | ||
- name: Display structure of downloaded files | ||
run: ls -R | ||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ needs.create-release.outputs.upload_url }} | ||
asset_path: ${{ needs.build.outputs.artifact }} | ||
asset_name: ${{ needs.build.outputs.artifact }} | ||
asset_content_type: application/zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters