Skip to content

Ci/add docker build and push to release please (#157) #53

Ci/add docker build and push to release please (#157)

Ci/add docker build and push to release please (#157) #53

on:
push:
branches:
- main
name: release-please
jobs:
release-please:
permissions:
pull-requests: write
contents: write
id-token: write
runs-on: ubuntu-latest
steps:
## Build a release based on the release-please-config.json file
- uses: google-github-actions/release-please-action@v3
id: release
with:
command: manifest
- uses: actions/checkout@v4
with:
fetch-depth: 0
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-go@v4
with:
go-version: stable
if: ${{ steps.release.outputs.release_created }}
## Use initium to build and push initium container
- name: build docker container using initium
run: go run main.go build
env:
INITIUM_APP_NAME: initium-cli
INITIUM_VERSION: ${{ steps.release.outputs.release_tag_name }}
INITIUM_REGISTRY_USER: ${{ github.actor }}
INITIUM_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
if: ${{ steps.release.outputs.release_created }}
- name: build docker container using initium
run: go run main.go push
env:
INITIUM_APP_NAME: initium-cli
INITIUM_VERSION: ${{ steps.release.outputs.release_tag_name }}
INITIUM_REGISTRY_USER: ${{ github.actor }}
INITIUM_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
if: ${{ steps.release.outputs.release_created }}
## Build go binary and add it to the release
- name: Build go binaries
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ steps.release.outputs.release_created }}
## Publish the release to npm
- uses: actions/checkout@v4
if: ${{ steps.release.outputs.release_created }}
- name: Get commit author
id: commit_author
run: |
author=$(gh pr list --search ${{ github.sha }} --state merged --json mergedBy --jq '.[0].mergedBy.login')
echo "author=${author}" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@v3
# This sets up the .npmrc file for publishing to npm
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
if: ${{ steps.release.outputs.release_created }}
- name: Run npm publish
shell: bash
run: |
cd npm
ln ../README.md README.md
./publish.sh
env:
NPM_TOKEN: ${{ secrets[format('NPM_TOKEN_{0}', steps.commit_author.outputs.author)] || secrets.NPM_TOKEN }}
OPTIC_TOKEN: ${{ secrets[format('OPTIC_TOKEN_{0}', steps.commit_author.outputs.author)] || secrets.OPTIC_TOKEN }}
if: ${{ steps.release.outputs.release_created }}