diff --git a/.github/actions/publish-release/action.yml b/.github/actions/publish-release/action.yml new file mode 100644 index 00000000..ecbbe627 --- /dev/null +++ b/.github/actions/publish-release/action.yml @@ -0,0 +1,39 @@ +name: "Publish Release" +description: "Publishes a release to Github and npm" + +inputs: + branchName: + description: 'The branch name of from which this release was triggered' + required: false + default: 'latest' + githubToken: + description: 'The Github auth token' + required: false + default: 'latest' + npmToken: + description: 'The npm auth token' + required: false + default: 'latest' + +runs: + using: "composite" + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Project + uses: ./setup + + - name: Build Project + run: npm run build + + - name: Semantic Release + run: npx semantic-release + env: + GITHUB_TOKEN: ${{ inputs.githubToken }} + + - name: Publish to npm + run: npm publish ./dist/*.tgz --tag ${{ inputs.tag }} + NODE_AUTH_TOKEN: ${{ inputs.npmToken }} diff --git a/.github/workflows/handle-release-branch-push.yml b/.github/workflows/handle-release-branch-push.yml new file mode 100644 index 00000000..081ab861 --- /dev/null +++ b/.github/workflows/handle-release-branch-push.yml @@ -0,0 +1,25 @@ +name: Handle Release Branch Push + +on: + push: + branches: + - 'alpha' + - 'beta' + - 'main' + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Project + uses: ./.github/actions/publish-release + with: + branchName: ${{ github.head_ref || github.ref_name }} + githubToken: ${{ secrets.GITHUB_TOKEN }} + npmToken: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish-github-release.yml b/.github/workflows/publish-github-release.yml deleted file mode 100644 index d4bc238d..00000000 --- a/.github/workflows/publish-github-release.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Publish Github Release - -on: - push: - branches: - - 'alpha' - - 'beta' - - 'main' - -jobs: - release: - runs-on: ubuntu-latest - env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup Project - uses: ./.github/actions/setup - - - name: Build Project - run: npm run build - - - name: Semantic Release - run: npx semantic-release - - - name: Publish to npm - run: npm publish ./dist/*.tgz --tag ${{ env.BRANCH_NAME == 'main' && 'latest' || '$BRANCH_NAME' }}