Skip to content

Commit

Permalink
Merge pull request #195 from IQSS/188-deploy-latest-develop-version
Browse files Browse the repository at this point in the history
Deploy Alpha GitHub action
  • Loading branch information
ekraffmiller authored Sep 26, 2024
2 parents 29998f9 + bb0dd8d commit e246194
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/deploy_alpha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: 'deploy_alpha'

on:
push:
branches:
- develop

jobs:
test-unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 19

- name: Install npm dependencies
run: npm ci

- name: Run unit tests
run: npm run test:unit

test-integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 19

- name: Install npm dependencies
run: npm ci

- name: Run integration tests
run: npm run test:integration

test-functional:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 19

- name: Install npm dependencies
run: npm ci

- name: Run functional tests
run: npm run test:functional

publish-gpr:
needs: [test-unit, test-integration, test-functional]
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 19
registry-url: https://npm.pkg.github.com/

- name: Install npm dependencies
run: npm ci

- name: Build package
run: npm run build

- name: Update package version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Fetch or initialize the version counter
if [ ! -f .alpha_version ]; then
echo "1" > .alpha_version
fi
INCREMENTAL_NUMBER=$(cat .alpha_version)
# Increment version number
NEW_INCREMENTAL_NUMBER=$((INCREMENTAL_NUMBER+1))
# Save the new incremental number to the file
echo "${NEW_INCREMENTAL_NUMBER}" > .alpha_version
# Update package version with 2.0.0-alpha.<incremental_number>
NEW_VERSION="2.0.0-alpha.${INCREMENTAL_NUMBER}"
npm version "${NEW_VERSION}" --no-git-tag-version
# Commit the version update and incremental number
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git add package.json .alpha_version
git commit -m "Update version to ${NEW_VERSION}"
# Push the changes to the repository
git push origin "${{ github.ref_name }}"
- name: Publish package
run: |
echo "$(jq '.publishConfig.registry = "https://npm.pkg.github.com"' package.json)" > package.json
echo "$( jq '.name = "@IQSS/dataverse-client-javascript"' package.json )" > package.json
npm publish --@IQSS:registry=https://npm.pkg.github.com
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 13 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ An unstable 2.x version of this package with breaking changes is under developme

Until a 2.0 version is officially released, it can be installed from https://github.com/IQSS/dataverse-client-javascript/pkgs/npm/dataverse-client-javascript

Two different versions are being pushed to the GitHub Packages registry:

1. **PR-Generated Versions**:

- These versions are generated from pull request commits.
- They follow the structure `2.0.0-pr<pr_number>.<commit_hash>`, where `pr_number` is the number of the pull request, and `commit_hash` is the specific commit hash from the PR branch.
- These versions are unstable and correspond to the state of the package during the pull request.

2. **Develop Alpha Versions**:
- These versions are generated on every commit made to the `develop` branch, ideally after each pull request is merged.
- They follow the structure `2.0.0-alpha.<number>`, where `number` is an incremental value that starts at 1 and increases with each build.
- These versions are also unstable and represent the latest work in progress on the `develop` branch.

### Create a `.npmrc` file and add a token

To install the [@iqss/dataverse-client-javascript](https://github.com/IQSS/dataverse-client-javascript/pkgs/npm/dataverse-client-javascript)
Expand Down

0 comments on commit e246194

Please sign in to comment.