snapshot-releasing chore/auto-snap-release #14
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: Snapshot Releasing | |
run-name: snapshot-releasing ${{ github.head_ref || github.ref_name }} | |
on: | |
push: | |
branches: | |
# Publish each time changeset-release branch is updated (which happens each time a changeset is merged to master) | |
- "changeset-release/**" | |
- chore/auto-snap-release # for testing remove me when done | |
# This workflow should on push to a changeset branch | |
# 1. checkout repo, install, build | |
# 2. version packages as a snapshot | |
# 3. publish packages to npm if there are any to be published || or exit success | |
# b. save a list of packages that were published | |
# 4. use the list to install the packages that were just published | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
env: | |
ACTIONS_STEP_DEBUG: true | |
jobs: | |
release: | |
name: Snapshot Release | |
runs-on: ['self-hosted', 'org', 'npm-publish'] | |
permissions: | |
contents: write | |
id-token: write | |
pull-requests: write | |
repository-projects: write | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
- name: Akeyless Get Secrets | |
id: get_auth_token | |
uses: | |
docker://us-west1-docker.pkg.dev/devopsre/akeyless-public/akeyless-action:latest | |
with: | |
api-url: https://api.gateway.akeyless.celo-networks-dev.org | |
access-id: p-kf9vjzruht6l | |
static-secrets: '{"/static-secrets/apps-tooling-circle/npm-publish-token":"NPM_TOKEN"}' | |
- name: Setup Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: 'Setup yarn' | |
shell: bash | |
run: | | |
npm install --global yarn | |
source ~/.bashrc | |
- name: Install Dependencies | |
shell: bash | |
run: yarn | |
- name: Build packages | |
shell: bash | |
run: yarn build | |
- name: Version packages | |
id: 'versioning' | |
run: yarn version --snapshot alpha | |
# when there are version changes "All files have been updated. Review them and commit at your leisure" | |
# when there are no version changes "No unreleased changesets found, exiting" | |
- name: Publish packages | |
run: echo PUBLISHED_PACKAGES=$(yarn --silent ts-node publish.ts) >> $GITHUB_OUTPUT | |
id: 'publishing' | |
- name: View output | |
run: echo ${{ steps.publishing.outputs.PUBLISHED_PACKAGES }} | |
# Publishing "@celo/phone-number-privacy-common" at "3.0.4-alpha-964a99345" | |
# id like to take all lines like the above and create an array of packages with form | |
# ["@celo/[email protected]"] | |
outputs: | |
# output array of packages like ["@celo/[email protected]"] | |
packages: ${{ steps.publishing.outputs.PUBLISHED_PACKAGES }} | |
example: "This is a static example" | |
install: | |
name: Install Snapshot Releases | |
needs: ['release'] | |
# if any packages where published install them else report success | |
if: ${{ needs.release.outputs.packages != 'no-op' }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
packages: ${{ fromJson(needs.release.outputs.packages) }} | |
steps: | |
# for each package call npm install package@version | |
- name: Install ${{ matrix.package }} | |
run: npm install ${{ matrix.package }} | |