diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 426a0891..ae40b3af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 actions@github.com - - 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/action-set-json-field@v2.1 @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d577dc4d..9d9bd802 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: release +name: Release on: workflow_dispatch: @@ -38,14 +38,15 @@ jobs: sync-semver-tags: true access: 'public' # This prefix is added before the prerelease number, e.g. `v3.0.0-next.0` - prerelease-prefix: 'next' + prerelease-prefix: 'alpha' semver: ${{ github.event.inputs.semver }} - # Prereleases are published under the `next` npm dist-tag - npm-tag: ${{ startsWith(github.event.inputs.semver, 'pre') && 'next' || 'latest' }} + # Prereleases are published under the `alpha` npm dist-tag + npm-tag: ${{ startsWith(github.event.inputs.semver, 'pre') && 'alpha' || 'latest' }} # Don't notify linked issues notify-linked-issues: false # optional: set this secret in your repo config for publishing to NPM npm-token: ${{ secrets.NPM_TOKEN }} + artifact-path: build build-command: | npm install npm run build