Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(var): init ci/cd #8

Merged
merged 2 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
85 changes: 85 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This workflow builds a xar archive, deploys it into exist and execute a simple smoke test.
# It also includes code for using semantic-release to upload packages as part of GitHub releases
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# For node free automated release see https://trstringer.com/github-actions-create-release-upload-artifacts/

name: exist-db CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# 7.0.0-SNAPSHOT and 6.2.1 created
exist-version: [latest, release]
java-version: [11, 17]
exclude:
- exist-version: release
java-version: 17
- exist-version: latest
java-version: 11

steps:
# Checkout code
- uses: actions/checkout@v4
- name: Install Test Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libxml2-utils bats
# sanity check
# TODO(DP) Validate ?
- name: Ensure all XML files are well-formed
run: |
xmllint --noout \
$(find . -type f -name '*.xml')

# Build
- name: Build Expath Package
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
- run: ant

# Install
- name: Start exist-ci containers
run: |
docker run -dit -p 8080:8080 -v ${{ github.workspace }}/build:/exist/autodeploy \
--name exist --rm --health-interval=2s --health-start-period=4s \
duncdrum/existdb:${{ matrix.exist-version }}
sleep 10s

# Test
- name: Run test
run: bats --tap test/*.bats

# Lint commit messages
- name: lint commit message
uses: wagoid/commitlint-github-action@v5

release:
name: Release
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version: lts/*
- name: Install dependencies
run: npm ci --no-optional
- name: Perform Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLIC_REPO: ${{ secrets.PUBLIC_REPO }}
run: npx semantic-release
# TODO(DP):
# - add secrets to github
# - publish to public repo?
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ build/*
.existdb.json
.DS_Store
expath-pkg.xml
repo.xml
repo.xml
.vscode/
.idea/
node_modules/
23 changes: 23 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"branches": ["master"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/exec", {
"prepareCmd": "ant -Dapp.version=${nextRelease.version}"
}],
["@semantic-release/git", {
"assets": ["package.json", "package-lock.json"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}],
["@semantic-release/github", {
"assets": [
{
"path": "build/other-publications-*.xar",
"name": "other-publications-${nextRelease.version}.xar",
"label": "Expath package (other-publications-${nextRelease.version}.xar)"
}
]
}]
]
}
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Other Publications

[![exist-db CI](https://github.com/HistoryAtState/other-publications/actions/workflows/build.yml/badge.svg)](https://github.com/HistoryAtState/other-publications/actions/workflows/build.yml)

Source data for:

- [Foreign Relations of the United States Guide to Sources on Vietnam, 1969-1975](https://history.state.gov/historicaldocuments/guide-to-sources-on-vietnam-1969-1975)
Expand All @@ -12,6 +14,27 @@ Source data for:
## Build

1. Single `xar` file: The `collection.xconf` will only contain the index, not any triggers!

```shell
ant
```
```

1. Since Releases have been automated when building locally you might want to supply your own version number (e.g. `X.X.X`) like this:

```shell
ant -Dapp.version=X.X.X
```

## Release

Releases for this data package are automated. Any commit to the `master` branch will trigger the release automation.

All commit message must conform to [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) to determine semantic versioning of releases, please adhere to these conventions, like so:

| Commit message | Release type |
|-----------------|--------------|
| `fix(pencil): stop graphite breaking when too much pressure applied` | Patch Release |
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
| `perf(pencil): remove graphiteWidth option`<br/><br/>`BREAKING CHANGE: The graphiteWidth option has been removed.`<br/>`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release |

When opening PRs commit messages are checked using commitlint.
3 changes: 2 additions & 1 deletion build.properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<name>other-publications</name>
<url>http://history.state.gov/ns/data/other-publications</url>
<title>Other Publications (data)</title>
<version>0.4</version>
<!-- VERSION SET AUTOMATICALLY DO NOT CHANGE -->
<!-- <version>0.4.0</version> -->
</app>
</root>
8 changes: 6 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@
<echo message="Creating xar file..."/>
<echo message="------------------------------------------------------------"/>

<zip basedir="${basedir}" destfile="${build.dir}/${app.name}-${app.version}.xar">
<zip basedir="${basedir}" destfile="${build.dir}/${app.name}.xar">
<exclude name="${build.dir}/**"/>
<exclude name="*.tmpl"/>
</zip>
<exclude name=".github/**"/>
<exclude name="test/**"/>
<exclude name="node_modules/**"/>
</zip>
<echo>Version: ${app.version}</echo>
</target>

<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present">
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-angular']}
Loading