Merge pull request #40 from FuelLabs/matt-user/refactor-migrate-packages #41
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: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
release-changesets: | |
name: Changesets Release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# need this to get full git-history/clone in order to build changelogs and check changesets | |
fetch-depth: 0 | |
- uses: FuelLabs/github-actions/setups/node@master | |
- uses: FuelLabs/github-actions/setups/npm@master | |
with: | |
npm-token: ${{ secrets.NPM_TOKEN }} | |
- name: Bump and Collect Version | |
run: | | |
pnpm changeset version | |
echo "BUILD_VERSION=$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' packages/jest/package.json)" >> $GITHUB_ENV | |
git reset --hard | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup git user (for changelog step) | |
run: | | |
git config --global user.name "${{ github.actor }}" | |
git config --global user.email "${{ github.actor }}@users.noreply.github.com" | |
- name: Build | |
run: pnpm build | |
env: | |
ASSETS_BASE_URL: 'https://cdn.fuel.network/assets/' | |
- name: Create Release Pull Request or Publish to NPM | |
id: changesets | |
uses: FuelLabs/changesets-action@main | |
with: | |
publish: pnpm changeset:release | |
commit: "ci(changesets): versioning packages" | |
title: "ci(changesets): versioning packages" | |
createGithubReleases: aggregate | |
githubReleaseName: v${{ env.BUILD_VERSION }} | |
githubTagName: v${{ env.BUILD_VERSION }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Release to @dev tag | |
if: steps.changesets.outputs.published != 'true' | |
run: | | |
git checkout main | |
pnpm changeset version --snapshot dev | |
pnpm changeset publish --tag dev | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Upload assets to S3 | |
- uses: unfor19/install-aws-cli-action@v1.0.3 | |
if: steps.changesets.outputs.published != 'true' | |
with: | |
version: 2 | |
verbose: false | |
arch: amd64 | |
rootdir: "" | |
workdir: "" | |
- uses: aws-actions/configure-aws-credentials@v1 | |
if: steps.changesets.outputs.published != 'true' | |
with: | |
aws-access-key-id: ${{ secrets.S3_CDN_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.S3_CDN_SECRET_KEY }} | |
aws-region: us-east-1 | |
- name: Upload assets to s3 | |
if: steps.changesets.outputs.published != 'true' | |
run: | | |
aws s3 cp ./packages/assets/images/ s3://${S3_CDN_BUCKET}/assets/ --recursive | |
env: | |
S3_CDN_BUCKET: ${{ secrets.S3_CDN_BUCKET }} |