-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace workflows with those from shared templates (#300)
* Replace workflows with those from shared templates * Updating version to 2.10.108 * Pass through build args * Checkout --------- Co-authored-by: dc-autobot[bot] <181364585+dc-autobot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
760146a
commit 993d469
Showing
6 changed files
with
67 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,215 +1,44 @@ | ||
name: Release | ||
|
||
name: Release (NPM) | ||
on: | ||
push: | ||
branches: ['main'] | ||
|
||
jobs: | ||
preconditions: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
repo_name: ${{ steps.repo_ids.outputs.REPO_NAME }} | ||
org_name: ${{ steps.repo_ids.outputs.ORG_NAME }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Check token | ||
run: | | ||
if [ -z "${{ secrets.GITHUB_TOKEN }}"]; then | ||
echo "Must provide a GITHUB_TOKEN secret in order to run release workflow" | ||
exit 1 | ||
fi | ||
- name: Get repository identifiers | ||
id: repo_ids | ||
run: | | ||
REPO_NAME=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]') | ||
ORG_NAME=$(echo "${{ github.event.repository.owner.name }}" | tr '[:upper:]' '[:lower:]') | ||
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_OUTPUT | ||
echo "ORG_NAME=$ORG_NAME" >> $GITHUB_OUTPUT | ||
lint: | ||
name: Run lint | ||
runs-on: ubuntu-latest | ||
needs: [preconditions] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18.x | ||
- name: Use npm latest | ||
run: npm install -g npm@latest | ||
- name: Cache Node.js modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS | ||
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.OS }}-node- | ||
${{ runner.OS }}- | ||
- name: Install Packages | ||
run: npm ci | ||
- name: Lint | ||
run: npm run lint | ||
dependency-check: | ||
name: Run dependency check | ||
runs-on: ubuntu-latest | ||
needs: [preconditions] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@master | ||
with: | ||
node-version: 18.x | ||
- name: Use npm latest | ||
run: npm install -g npm@latest | ||
- name: Cache Node.js modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS | ||
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.OS }}-node- | ||
${{ runner.OS }}- | ||
- name: Install Packages | ||
run: npm ci | ||
- name: Dependency Check | ||
run: npm run depcheck | ||
static-checks-npm: | ||
uses: digicatapult/shared-workflows/.github/workflows/static-checks-npm.yml@main | ||
with: | ||
matrix_commands: '["lint", "depcheck"]' | ||
tests: | ||
name: Run tests | ||
runs-on: ubuntu-latest | ||
needs: [preconditions] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@master | ||
with: | ||
node-version: 18.x | ||
- name: Use npm latest | ||
run: npm install -g npm@latest | ||
- name: Cache Node.js modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS | ||
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.OS }}-node- | ||
${{ runner.OS }}- | ||
- name: Install Packages | ||
run: npm ci | ||
- name: Setup dependencies | ||
run: docker compose up -d | ||
- name: Sleep | ||
uses: kibertoad/[email protected] | ||
with: | ||
time: '30s' | ||
- name: Run tests | ||
run: npm run test | ||
check-version: | ||
name: 'Check version' | ||
uses: digicatapult/shared-workflows/.github/workflows/tests-npm.yml@main | ||
with: | ||
tests: '["test"]' | ||
kubo-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
is_new_version: ${{ steps.get_version.outputs.IS_NEW_VERSION }} | ||
version: ${{ steps.get_version.outputs.VERSION }} | ||
build_date: ${{ steps.get_version.outputs.BUILD_DATE }} | ||
is_prerelease: ${{ steps.get_version.outputs.IS_PRERELEASE }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Check version | ||
id: get_version | ||
uses: digicatapult/check-version@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
publish: | ||
name: 'Publish package' | ||
needs: | ||
- preconditions | ||
- lint | ||
- dependency-check | ||
- tests | ||
- check-version | ||
runs-on: ubuntu-latest | ||
if: ${{ needs.check-version.outputs.is_new_version == 'true' }} | ||
|
||
ipfs_tag: ${{ steps.kubo_version.outputs.IPFS_TAG }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get Kubo Version | ||
id: kubo_version | ||
run: | | ||
echo "IPFS_TAG=v$(jq .devDependencies.kubo ./package.json | sed 's/[\^"]//g')" >> $GITHUB_OUTPUT | ||
# Docker build | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
platforms: all | ||
- name: Setup Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
buildkitd-flags: '--debug' | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Login to Dockerhub Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.SQNC_DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.SQNC_DOCKERHUB_TOKEN }} | ||
- name: Publish multi-arch image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
builder: ${{ steps.buildx.outputs.name }} | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64, linux/arm64 | ||
build-args: | | ||
IPFS_TAG=${{ steps.kubo_version.outputs.IPFS_TAG }} | ||
tags: | | ||
ghcr.io/${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:${{ needs.check-version.outputs.version }} | ||
${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:${{ needs.check-version.outputs.version }} | ||
ghcr.io/${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:latest | ||
${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:latest | ||
labels: | | ||
org.opencontainers.image.title=${{ needs.preconditions.outputs.repo_name }} | ||
org.opencontainers.image.description=${{ github.event.repository.description }} | ||
org.opencontainers.image.source=${{ github.event.repository.html_url }} | ||
org.opencontainers.image.url=${{ github.event.repository.html_url }} | ||
org.opencontainers.image.revision=${{ github.sha }} | ||
org.opencontainers.image.version=${{ needs.check-version.outputs.version }} | ||
org.opencontainers.image.created=${{ needs.check-version.outputs.build_date }} | ||
# Build github release | ||
- name: Build release version | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
token: '${{ secrets.GITHUB_TOKEN }}' | ||
tag_name: ${{ needs.check-version.outputs.version }} | ||
prerelease: false | ||
name: ${{ needs.check-version.outputs.version }} | ||
generate_release_notes: true | ||
- name: Delete release latest | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const { owner, repo } = context.repo | ||
try { | ||
await github.rest.git.deleteRef({ owner, repo, ref: 'tags/latest' }) | ||
} | ||
catch (err) { | ||
if (err.status !== 422) throw err | ||
} | ||
- name: Build release latest | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
token: '${{ secrets.GITHUB_TOKEN }}' | ||
tag_name: latest | ||
prerelease: false | ||
name: Latest ${{ needs.check-version.outputs.version }} | ||
generate_release_notes: true | ||
build-docker: | ||
needs: [tests, static-checks-npm, kubo-version] | ||
uses: digicatapult/shared-workflows/.github/workflows/build-docker.yml@main | ||
with: | ||
push_dockerhub: true | ||
push_ghcr: true | ||
build_args: | | ||
IPFS_TAG=${{ needs.kubo-version.outputs.ipfs_tag }} | ||
permissions: | ||
packages: write | ||
contents: write | ||
secrets: | ||
DOCKERHUB_TOKEN: ${{ secrets.SQNC_DOCKERHUB_TOKEN }} | ||
DOCKERHUB_USERNAME: ${{ secrets.SQNC_DOCKERHUB_USERNAME }} | ||
release-github: | ||
needs: [build-docker] | ||
uses: digicatapult/shared-workflows/.github/workflows/release-github.yml@main | ||
permissions: | ||
contents: write | ||
pull-requests: read | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Test (NPM) | ||
on: | ||
push: | ||
branches-ignore: ['main'] | ||
jobs: | ||
static-checks-npm: | ||
uses: digicatapult/shared-workflows/.github/workflows/static-checks-npm.yml@main | ||
with: | ||
matrix_commands: '["lint", "depcheck"]' | ||
tests: | ||
uses: digicatapult/shared-workflows/.github/workflows/tests-npm.yml@main | ||
with: | ||
tests: '["test"]' | ||
kubo-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
ipfs_tag: ${{ steps.kubo_version.outputs.IPFS_TAG }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get Kubo Version | ||
id: kubo_version | ||
run: | | ||
echo "IPFS_TAG=v$(jq .devDependencies.kubo ./package.json | sed 's/[\^"]//g')" >> $GITHUB_OUTPUT | ||
build-docker: | ||
uses: digicatapult/shared-workflows/.github/workflows/build-docker.yml@main | ||
needs: | ||
- kubo-version | ||
permissions: | ||
packages: write | ||
contents: write | ||
with: | ||
build_args: | | ||
IPFS_TAG=${{ needs.kubo-version.outputs.ipfs_tag }} |
Oops, something went wrong.