Github Release #70
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
# release package | |
name: Github Release | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "v*.*.*" | |
jobs: | |
build-binaries: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
env: | |
TARBALL_TARGETS: linux-x64,linux-arm64,darwin-x64,darwin-arm64,win32-x64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE }} | |
aws-region: us-west-2 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18.x' | |
cache: yarn | |
- run: yarn | |
- run: yarn build | |
- uses: actions/cache@v3 | |
id: cache-oclif-pack | |
name: setup cache for oclif pack | |
with: | |
path: packages/cli/tmp/cache | |
key: preevy-oclif-pack-node18 | |
- name: pack tarballs | |
working-directory: packages/cli | |
run: yarn oclif pack tarballs --parallel --no-xz --targets $TARBALL_TARGETS | |
- name: upload tarballs | |
working-directory: packages/cli | |
run: yarn oclif upload tarballs --no-xz --targets $TARBALL_TARGETS | |
- name: create redirects to version without git sha | |
# if: startsWith(github.ref, 'refs/tags/') | |
working-directory: packages/cli | |
run: | | |
bucket="$(jq -r .oclif.update.s3.bucket package.json)" | |
version=$(jq -r .version package.json) | |
git_sha="$(git rev-parse --short HEAD)" | |
temp_file="${RUNNER_TEMP}/redir_${RANDOM}" | |
function create_s3_redirect() { | |
local from=$1 | |
local to=$2 | |
echo "Redirecting to ${to}" > "${temp_file}" | |
echo "Creating redirect from ${from} to ${to}" | |
aws s3 cp "${temp_file}" "s3://${bucket}${from}" --quiet --website-redirect "${to}" --acl public-read | |
} | |
for target in ${TARBALL_TARGETS//,/ }; do | |
for suffix in .tar.gz -buildmanifest; do | |
create_s3_redirect /versions/${version}/preevy-v${version}-${target}${suffix} /versions/${version}/preevy-v${version}-${git_sha}-${target}${suffix} | |
done | |
done | |
- name: rename tarballs | |
# if: startsWith(github.ref, 'refs/tags/') | |
working-directory: packages/cli/dist | |
run: | | |
git_sha="$(git rev-parse --short HEAD)" | |
for f in $(find . -maxdepth 1 -type f -name 'preevy-v*'); do | |
new_name="$(echo ${f} | sed 's/-'"${git_sha}"'//')" | |
echo "Renaming ${f} to ${new_name}" | |
mv "${f}" "${new_name}" | |
done | |
- name: release | |
uses: softprops/action-gh-release@v1 | |
with: | |
generate_release_notes: true | |
draft: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
files: | | |
packages/cli/dist/preevy-v*.tar.gz | |
packages/cli/dist/preevy-v*-buildmanifest |