Skip to content

Commit

Permalink
feat: setup semantic release
Browse files Browse the repository at this point in the history
  • Loading branch information
plexoos committed Apr 25, 2024
1 parent 23183af commit 71446f4
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/delete_untagged.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3

import argparse
import json
import requests
import types

parser = argparse.ArgumentParser()
parser.add_argument("token", help="GitHub token")
args = parser.parse_args()

domain = "api.github.com"
org = "BNLNPPS"
package_type = "container"
package_name = "esi-opticks"

api_url = f"https://{domain}/orgs/{org}/packages/{package_type}/{package_name}/versions"

respjson = requests.get(api_url, auth=("token", args.token))
entries = json.loads(respjson.text, object_hook=lambda d: types.SimpleNamespace(**d))

for e in entries:
if not e.metadata.container.tags:
response = requests.delete(api_url + f"/{e.id}", auth=("token", args.token))
print("delete", e.id, e.html_url, e.name, response.url, response.status_code)
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Release

on:
push:
branches:
- semrel

jobs:
build-test-release:
runs-on: ubuntu-latest
steps:
- name: Define environment variables
run: echo IMAGE_NAME=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Important for Semantic Release to analyze all commits

- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3

- name: Build container
uses: docker/build-push-action@v5
with:
file: Dockerfile.test
tags: ${{ env.IMAGE_NAME }}:pre-semver
load: true
cache-from: ${{ env.IMAGE_NAME }}:latest

- name: Run tests
run: docker run ${{ env.IMAGE_NAME }}:pre-semver curl --version

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ steps.semantic.outputs.new_release_git_tag }}

- name: Login to GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build container
uses: docker/build-push-action@v5
with:
file: Dockerfile.test
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ steps.semantic.outputs.new_release_version }}
push: true
cache-from: ${{ env.IMAGE_NAME }}:pre-semver

cleanup:
runs-on: ubuntu-latest
needs: build-test-release
steps:
- name: Checkout code
uses: actions/checkout@v4
- run: .github/workflows/delete_untagged.py ${{ secrets.GITHUB_TOKEN }}
15 changes: 15 additions & 0 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# See https://semantic-release.gitbook.io/semantic-release/usage/configuration
branches:
- semrel
tagFormat: '${version}' # without this, the tag is prefixed with a 'v'
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/changelog"
- path: "@semantic-release/npm"
npmPublish: false
- path: "@semantic-release/git"
assets:
- "CHANGELOG.md"
- "package.json"
message: "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
## [1.1.4](https://github.com/BNLNPPS/esi-opticks/compare/1.1.3...1.1.4) (2024-04-25)


### Bug Fixes

* use github token ([4d8c086](https://github.com/BNLNPPS/esi-opticks/commit/4d8c08688d51d5f53df700a98d431280d576278a))

## [1.1.3](https://github.com/BNLNPPS/esi-opticks/compare/1.1.2...1.1.3) (2024-04-25)


### Bug Fixes

* use token ([6b80ed1](https://github.com/BNLNPPS/esi-opticks/commit/6b80ed1da4f1c06bf4f55e158d9b4e0bfd57b98b))

## [1.1.2](https://github.com/BNLNPPS/esi-opticks/compare/1.1.1...1.1.2) (2024-04-25)


### Bug Fixes

* make executable ([d324a4a](https://github.com/BNLNPPS/esi-opticks/commit/d324a4a8e23a9046a0835c2aaa36de224156b50d))

## [1.1.1](https://github.com/BNLNPPS/esi-opticks/compare/1.1.0...1.1.1) (2024-04-25)


### Bug Fixes

* update permission ([57b9990](https://github.com/BNLNPPS/esi-opticks/commit/57b99906617e4360c511e4eeb06e8c7ffd4c5edc))

# [1.1.0](https://github.com/BNLNPPS/esi-opticks/compare/1.0.0...1.1.0) (2024-04-25)


### Features

* delete untagged images ([2d5c4d5](https://github.com/BNLNPPS/esi-opticks/commit/2d5c4d55f92648441a60f49b900923bbc42c404d))

# 1.0.0 (2024-04-25)


### Bug Fixes

* **build:** keep build cache dir ([#21](https://github.com/BNLNPPS/esi-opticks/issues/21)) ([d81672d](https://github.com/BNLNPPS/esi-opticks/commit/d81672d8f4a08532e2719851320ee9e3112cb5a5))
* **esi-shell:** avoid building code (OptiX) on shell startup ([#23](https://github.com/BNLNPPS/esi-opticks/issues/23)) ([76320cf](https://github.com/BNLNPPS/esi-opticks/commit/76320cf6e8d43e37414d0469ae8f81c950f97231))
* **esi-shell:** drop support for singularity with GPU (for now) ([#22](https://github.com/BNLNPPS/esi-opticks/issues/22)) ([4cb9d19](https://github.com/BNLNPPS/esi-opticks/commit/4cb9d19c3180ac66aab8d58a4e615cd4e0e6567e))
* **esi-shell:** improve user experience ([#20](https://github.com/BNLNPPS/esi-opticks/issues/20)) ([0a464af](https://github.com/BNLNPPS/esi-opticks/commit/0a464af1dd9d01cedb98dd50b3f3681dbe73da22))
* **esi-shell:** support only linux ([#13](https://github.com/BNLNPPS/esi-opticks/issues/13)) ([6cfb154](https://github.com/BNLNPPS/esi-opticks/commit/6cfb154d82fe252089b10ef92db3a63707c2a60b))
* patch spack default modules.yaml ([#27](https://github.com/BNLNPPS/esi-opticks/issues/27)) ([23183af](https://github.com/BNLNPPS/esi-opticks/commit/23183af24648db3fdcdf0c5a9dc94385d9aa1b9c))
* set compute capability to 5.2 compatible with Quadro M4000 ([#1](https://github.com/BNLNPPS/esi-opticks/issues/1)) ([b1d7513](https://github.com/BNLNPPS/esi-opticks/commit/b1d751357c61ac3e18a94262536ca397d1fa54e7))
* simplify build workflow, leverage login scripts ([#8](https://github.com/BNLNPPS/esi-opticks/issues/8)) ([fd974b4](https://github.com/BNLNPPS/esi-opticks/commit/fd974b4c42dbcb8c1247cd262bafbf16e4eb071b))
* use correct gdml file ([c014536](https://github.com/BNLNPPS/esi-opticks/commit/c014536e4452a815bef61a2b03bfe456a898bb7d))


### Features

* add esi-shell ([#6](https://github.com/BNLNPPS/esi-opticks/issues/6)) ([fa859aa](https://github.com/BNLNPPS/esi-opticks/commit/fa859aa91496b27fb66d891ef78a28ec90b45c50))
* setup semantic release ([0515111](https://github.com/BNLNPPS/esi-opticks/commit/0515111b81f304db1014417a70a160fa5525c0b9))
* upgrade opticks to main@b55f15bd ([#26](https://github.com/BNLNPPS/esi-opticks/issues/26)) ([946da36](https://github.com/BNLNPPS/esi-opticks/commit/946da36cdc7fe309c63a8547ca8aeeeb0551a313))
7 changes: 7 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# syntax=docker/dockerfile:latest

FROM nvcr.io/nvidia/cuda:11.8.0-runtime-ubuntu22.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y curl
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "esi-opticks",
"version": "1.1.4",
"description": "esi shell project",
"repository": {
"type": "git",
"url": "git+https://github.com/BNLNPPS/esi-opticks.git"
},
"keywords": [],
"author": "BNL NPPS",
"license": "MIT",
"bugs": {
"url": "https://github.com/BNLNPPS/esi-opticks/issues"
},
"homepage": "https://github.com/BNLNPPS/esi-opticks#readme",
"devDependencies": {
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^12.0.0",
"@semantic-release/git": "^10.0.1",
"@semantic-release/release-notes-generator": "^13.0.0",
"semantic-release": "^23.0.8"
}
}

0 comments on commit 71446f4

Please sign in to comment.