Merge pull request #4892 from berty/dependabot/npm_and_yarn/js/web/na… #10
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
name: Release | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
paths: | |
# Go | |
- "go/**" | |
- "!go/**.md" | |
- ".goreleaser" | |
- "go.*" | |
- "**.go" | |
# CI | |
- ".github/workflows/release.yml" | |
- "tool/publish-npm-package" | |
# NPM package | |
- "./js/packages/api" | |
jobs: | |
semantic-release: | |
name: Semantic release | |
runs-on: ubuntu-latest | |
outputs: | |
new-release-published: ${{ steps.semantic-echo.outputs.new-release-published }} | |
release-version: ${{ steps.semantic-echo.outputs.release-version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Unshallow | |
run: git fetch --prune --unshallow | |
- name: Run Semantic Release | |
id: semantic | |
uses: docker://ghcr.io/codfish/semantic-release-action:v1 | |
with: | |
branches: | | |
['master'] | |
plugins: | | |
[ | |
'@semantic-release/commit-analyzer', | |
'@semantic-release/release-notes-generator', | |
'@semantic-release/github' | |
] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Export Semantic Release | |
id: semantic-echo | |
run: | | |
echo "::set-output name=new-release-published::${{steps.semantic.outputs.new-release-published}}" | |
echo "::set-output name=release-version::${{steps.semantic.outputs.release-version}}" | |
release-on-stores: | |
name: Release on stores | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup asdf | |
uses: asdf-vm/actions/setup@v1 | |
- name: Setup jq | |
run: | | |
asdf plugin add jq | |
asdf install jq | |
- name: Get last commit message | |
env: | |
EVENT: ${{ toJson(github.event) }} | |
run: | | |
echo "$EVENT" > $RUNNER_TEMP/event | |
echo "commit_message=$(jq '. | |
| select(.commits != null) | |
| .after as $last_commit | |
| .commits | |
| map(select(.id == $last_commit))[0].message' $RUNNER_TEMP/event)" >> $GITHUB_ENV | |
- name: Dispatch event to release repo | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.REPOSITORY_DISPATCH }} | |
script: | | |
await github.rest.repos.createDispatchEvent({ | |
owner: 'berty', | |
repo: 'release-on-stores', | |
event_type: 'release', | |
client_payload: {"commit_message":${{ env.commit_message }}}, | |
}) | |
post-semantic-release: | |
needs: semantic-release | |
#if: needs.semantic-release.outputs.new-release-published == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Unshallow | |
run: git fetch --prune --unshallow | |
- name: Setup asdf | |
uses: asdf-vm/actions/setup@v1 | |
- name: Setup go | |
run: | | |
asdf plugin add golang | |
asdf install golang | |
- name: Setup node | |
if: needs.semantic-release.outputs.new-release-published == 'true' | |
run: | | |
asdf plugin add nodejs | |
asdf install nodejs | |
- name: "Publish npm package: @berty/api (Real)" | |
if: needs.semantic-release.outputs.new-release-published == 'true' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
continue-on-error: true | |
working-directory: tool/publish-npm-package | |
run: go run . -path=../../js/packages/api -version=${{ needs.semantic-release.outputs.release-version }} | |
# Next step also sets up a .npmrc file for automatic publishing to npm | |
- name: "Publish npm package: @berty/api (DryRun)" | |
if: needs.semantic-release.outputs.new-release-published != 'true' | |
working-directory: tool/publish-npm-package | |
run: go run . -path=../../js/packages/api -version=0.0.0 -dry-run | |
- name: Register version on pkg.go.dev | |
if: needs.semantic-release.outputs.new-release-published == 'true' | |
run: | | |
package=$(cat go.mod | grep ^module | awk '{print $2}') | |
version=v${{ needs.semantic-release.outputs.release-version }} | |
url=https://proxy.golang.org/${package}/@v/${version}.info | |
set -x +e | |
curl -i $url | |
build-asset: | |
needs: semantic-release | |
name: build asset | |
runs-on: ${{ matrix.config.runs-on }} | |
strategy: | |
matrix: | |
config: [ | |
# @FIXME(gfanton): latest ubuntu version broke `Install Linux Dependencies` step | |
{ runs-on: "ubuntu-20.04", goos: "linux" }, | |
{ runs-on: "macos-latest", goos: "darwin" }, | |
{ runs-on: "windows-latest", goos: "windows" }, | |
# TODO: bertyguy | |
] | |
env: | |
OSXCROSS_DIR: /home/runner/work/osxcross | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Unshallow | |
run: git fetch --prune --unshallow | |
- name: Load variables from file | |
uses: antifree/[email protected] | |
with: | |
filename: .github/workflows/utils/variables.json | |
- name: Setup asdf (Posix) | |
if: matrix.config.goos != 'windows' | |
uses: asdf-vm/actions/setup@v1 | |
- name: Setup go (Posix) | |
if: matrix.config.goos != 'windows' | |
run: | | |
asdf plugin add golang | |
asdf install golang | |
echo "go_version=$(asdf current golang | xargs | cut -d ' ' -f 2)" >> $GITHUB_ENV | |
- name: Get go version (Windows) | |
if: matrix.config.goos == 'windows' | |
shell: bash | |
run: echo "go_version=$(cat .tool-versions | grep '^golang [0-9]\+\.[0-9]\+\.[0-9]\+.*$' | cut -d ' ' -f 2)" >> $GITHUB_ENV | |
- name: Setup go (Windows) | |
if: matrix.config.goos == 'windows' | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.go_version }} | |
- name: Cache go modules | |
uses: actions/[email protected] | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-${{ hashFiles('go/**/go.sum') }} | |
restore-keys: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}- | |
- name: Install Linux Dependencies | |
if: matrix.config.goos == 'linux' | |
run: | | |
echo 'deb http://security.ubuntu.com/ubuntu bionic-security main' | sudo tee -a /etc/apt/sources.list | |
sudo apt update | |
sudo apt-cache policy libssl1.0-dev | |
sudo apt install -f libssl1.0-dev | |
sudo apt install -f gcc-multilib g++-multilib gcc-mingw-w64 clang | |
sudo apt install -f -y libgl1-mesa-glx libgl1-mesa-dev xorg-dev | |
mkdir ../../osxcross | |
git clone https://github.com/plentico/osxcross-target.git ../../osxcross/target | |
- name: Run GoReleaser (DryRun) | |
uses: goreleaser/goreleaser-action@v3 | |
if: needs.semantic-release.outputs.new-release-published != 'true' | |
with: | |
version: latest | |
args: release --clean -f .github/workflows/utils/.goreleaser.${{ matrix.config.goos }}.yml --skip=publish | |
- name: Run GoReleaser (Publish) | |
uses: goreleaser/goreleaser-action@v3 | |
if: needs.semantic-release.outputs.new-release-published == 'true' | |
with: | |
version: latest | |
args: release --clean -f .github/workflows/utils/.goreleaser.${{ matrix.config.goos }}.yml | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Dist/ directory listing (Posix) | |
if: matrix.config.goos != 'windows' | |
run: ls -lah dist | |
- name: Dist/ directory listing (Windows) | |
if: matrix.config.goos == 'windows' | |
run: Get-ChildItem -Recurse dist |