From c421a92e19511f7adf66f90175e28f3b98e7204e Mon Sep 17 00:00:00 2001 From: Garrett Reinard Date: Fri, 8 Sep 2023 13:24:25 -0400 Subject: [PATCH] Adjust cicd workflows to publish release and snapshot/prerelease tags slightly differently. --- .../workflows/{cicd.yml => cicd-release.yml} | 3 +- .github/workflows/cicd-snapshot.yml | 35 +++++++++++++++++++ Snapshot.ps1 | 12 +++++++ 3 files changed, 49 insertions(+), 1 deletion(-) rename .github/workflows/{cicd.yml => cicd-release.yml} (94%) create mode 100644 .github/workflows/cicd-snapshot.yml create mode 100644 Snapshot.ps1 diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd-release.yml similarity index 94% rename from .github/workflows/cicd.yml rename to .github/workflows/cicd-release.yml index 3809623d..0fb9bace 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd-release.yml @@ -1,10 +1,11 @@ -name: Publish to npmjs +name: Publish to npmjs and ProGet (releases) on: workflow_dispatch: push: tags: - '*.*.*' + - "!*-*" permissions: id-token: write diff --git a/.github/workflows/cicd-snapshot.yml b/.github/workflows/cicd-snapshot.yml new file mode 100644 index 00000000..df80dc8e --- /dev/null +++ b/.github/workflows/cicd-snapshot.yml @@ -0,0 +1,35 @@ +name: Publish to npmjs and ProGet (snapshots / prereleases) + +on: + workflow_dispatch: + push: + tags: + - "*-*" + +permissions: + id-token: write + contents: read + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: "17.3.0" + - name: Install Dependencies + run: npm ci + - name: Run Build + run: npm run rollup + - name: Deploy to npmjs + run: | + npm config set @careevolution:registry=https://registry.npmjs.org/ + npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPMJS_TOKEN }} + npm publish --tag next --access public + - name: Deploy to ProGet + run: | + echo "@careevolution:registry=https://proget.careevolution.com/npm/npm/" > .npmrc + npm config set @careevolution:registry=https://proget.careevolution.com/npm/npm/ + npm config set //proget.careevolution.com/npm/npm/:_authToken ${{ secrets.PROGET_TOKEN }} + npm publish --tag next \ No newline at end of file diff --git a/Snapshot.ps1 b/Snapshot.ps1 new file mode 100644 index 00000000..31078fb3 --- /dev/null +++ b/Snapshot.ps1 @@ -0,0 +1,12 @@ +$branch= &git rev-parse --abbrev-ref HEAD + +if($branch -eq "main"){ + throw 'Cannot snapshot the main branch' +} + +$branch = ($branch -split "/")[-1] + +$newVersion = npm version prerelease --preid $branch +echo $newVersion +git push +git push origin $newVersion \ No newline at end of file