From fdc34a34f19eff9a6170a88579bf8879b18a12c3 Mon Sep 17 00:00:00 2001 From: Reese Williams Date: Wed, 20 Dec 2023 04:33:48 +0000 Subject: [PATCH 1/6] Automatically create prerelease release on non-tagged master builds --- .github/workflows/preview-release.yaml | 117 +++++++++++++++++++++++++ .github/workflows/release.yaml | 2 +- script/make_release | 2 +- 3 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/preview-release.yaml diff --git a/.github/workflows/preview-release.yaml b/.github/workflows/preview-release.yaml new file mode 100644 index 00000000..2c4a9ded --- /dev/null +++ b/.github/workflows/preview-release.yaml @@ -0,0 +1,117 @@ +name: Preview Release +on: + workflow_run: + workflows: ["CI"] + types: + - completed + push: + # Run only on trunk pushes that aren't a new tag release + branches: [trunk] + tags-ignore: "*" + +env: + BUNDLE_PATH: /tmp/.bundle + GEM_HOME: /tmp/.bundle + GEM_PATH: /tmp/.bundle + TERM: xterm256 + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-20.04 + target: native + - os: macos-latest + target: native + - os: ubuntu-20.04 + target: aarch64-unknown-linux-gnu + steps: + - uses: actions/checkout@v2 + with: + submodules: true + fetch-depth: 0 + - if: runner.os == 'macOS' + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.63.0 + target: aarch64-apple-darwin + default: true + override: true + profile: minimal + - if: runner.os != 'macOS' + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.63.0 + override: true + profile: minimal + target: aarch64-unknown-linux-gnu + - uses: actions/cache@v2 + with: + path: | + librubyfmt/ruby_checkout + key: ${{ runner.os }}-${{matrix.target}}-ruby-v1-${{ hashFiles('.git/modules/librubyfmt/ruby_checkout/HEAD') }} + - if: runner.os == 'macOS' + run: | + brew install automake bison + echo "/usr/local/opt/bison/bin:$PATH" >> $GITHUB_PATH + - run: ./script/make_release + - uses: actions/upload-artifact@v3 + with: + name: rubyfmt-release-artifact-${{ matrix.os }}-${{ matrix.target }} + path: rubyfmt-*.tar.gz + source-release: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: true + fetch-depth: 0 + - run: | + TAG=$(git describe HEAD) + RELEASE_DIR="out/release" + mkdir -p ${RELEASE_DIR} + ./script/make_source_release ${TAG} + - uses: actions/upload-artifact@v3 + with: + name: rubyfmt-source-release + path: "out/release/source" + release: + runs-on: ubuntu-latest + needs: + - build + - source-release + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v3 + with: + name: rubyfmt-source-release + - uses: actions/download-artifact@v3 + with: + name: rubyfmt-release-artifact-ubuntu-20.04-native + - uses: actions/download-artifact@v3 + with: + name: rubyfmt-release-artifact-ubuntu-20.04-aarch64-unknown-linux-gnu + - uses: actions/download-artifact@v3 + with: + name: rubyfmt-release-artifact-macos-latest-native + - uses: actions-ecosystem/action-get-latest-tag@v1 + id: get-latest-tag + - uses: actions-ecosystem/action-bump-semver@v1 + id: bump-semver + with: + current_version: ${{ steps.get-latest-tag.outputs.tag }} + level: prepatch + - uses: actions-ecosystem/action-push-tag@v1 + with: + tag: ${{ steps.bump-semver.outputs.new_version }} + - name: Upload Release + uses: softprops/action-gh-release@v1 + with: + files: rubyfmt-*.tar.gz + fail_on_unmatched_files: true + generate_release_notes: true + prerelease: true + tag_name: ${{steps.bump-semver.outputs.new_version}} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8a8a0209..1ef26a6f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-latest + - os: ubuntu-20.04 target: native - os: macos-latest target: native diff --git a/script/make_release b/script/make_release index 9234bfb7..a94043cc 100755 --- a/script/make_release +++ b/script/make_release @@ -7,7 +7,7 @@ if [[ $OSTYPE == "darwin"* ]]; then fi bison --version -TAG=$(git describe --exact-match HEAD) +TAG=$(git describe --tags --abbrev=0) RELEASE_DIR=${RELEASE_DIR:-"tmp/releases/${TAG}-$(uname -s)/"} ./script/test.sh From 6116f6f9bd7df681bf7ad7a3e387f25161619534 Mon Sep 17 00:00:00 2001 From: Reese Williams Date: Wed, 20 Dec 2023 04:42:18 +0000 Subject: [PATCH 2/6] Push tags first --- .github/workflows/preview-release.yaml | 43 ++++++++++++++++---------- script/make_release | 2 +- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/.github/workflows/preview-release.yaml b/.github/workflows/preview-release.yaml index 2c4a9ded..9604ac7b 100644 --- a/.github/workflows/preview-release.yaml +++ b/.github/workflows/preview-release.yaml @@ -6,7 +6,7 @@ on: - completed push: # Run only on trunk pushes that aren't a new tag release - branches: [trunk] + branches: "*" tags-ignore: "*" env: @@ -16,8 +16,23 @@ env: TERM: xterm256 jobs: + bump-tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-ecosystem/action-get-latest-tag@v1 + id: get-latest-tag + - uses: actions-ecosystem/action-bump-semver@v1 + id: bump-semver + with: + current_version: ${{ steps.get-latest-tag.outputs.tag }} + level: prepatch + - uses: actions-ecosystem/action-push-tag@v1 + with: + tag: ${{ steps.bump-semver.outputs.new_version }} build: runs-on: ${{ matrix.os }} + needs: [bump-tag] strategy: fail-fast: false matrix: @@ -99,19 +114,13 @@ jobs: name: rubyfmt-release-artifact-macos-latest-native - uses: actions-ecosystem/action-get-latest-tag@v1 id: get-latest-tag - - uses: actions-ecosystem/action-bump-semver@v1 - id: bump-semver - with: - current_version: ${{ steps.get-latest-tag.outputs.tag }} - level: prepatch - - uses: actions-ecosystem/action-push-tag@v1 - with: - tag: ${{ steps.bump-semver.outputs.new_version }} - - name: Upload Release - uses: softprops/action-gh-release@v1 - with: - files: rubyfmt-*.tar.gz - fail_on_unmatched_files: true - generate_release_notes: true - prerelease: true - tag_name: ${{steps.bump-semver.outputs.new_version}} + - run: | + echo "${{ steps.get-latest-tag.outputs.tag }}" + # - name: Upload Release + # uses: softprops/action-gh-release@v1 + # with: + # files: rubyfmt-*.tar.gz + # fail_on_unmatched_files: true + # generate_release_notes: true + # prerelease: true + # tag_name: ${{ steps.get-latest-tag.outputs.tag }} diff --git a/script/make_release b/script/make_release index a94043cc..9234bfb7 100755 --- a/script/make_release +++ b/script/make_release @@ -7,7 +7,7 @@ if [[ $OSTYPE == "darwin"* ]]; then fi bison --version -TAG=$(git describe --tags --abbrev=0) +TAG=$(git describe --exact-match HEAD) RELEASE_DIR=${RELEASE_DIR:-"tmp/releases/${TAG}-$(uname -s)/"} ./script/test.sh From 4bf574e782a164da5c541e9c904a5bda28e0c9fa Mon Sep 17 00:00:00 2001 From: Reese Williams Date: Wed, 20 Dec 2023 05:21:01 +0000 Subject: [PATCH 3/6] For real now --- .github/workflows/preview-release.yaml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/preview-release.yaml b/.github/workflows/preview-release.yaml index 9604ac7b..e0a74698 100644 --- a/.github/workflows/preview-release.yaml +++ b/.github/workflows/preview-release.yaml @@ -6,7 +6,7 @@ on: - completed push: # Run only on trunk pushes that aren't a new tag release - branches: "*" + branches: [trunk] tags-ignore: "*" env: @@ -114,13 +114,11 @@ jobs: name: rubyfmt-release-artifact-macos-latest-native - uses: actions-ecosystem/action-get-latest-tag@v1 id: get-latest-tag - - run: | - echo "${{ steps.get-latest-tag.outputs.tag }}" - # - name: Upload Release - # uses: softprops/action-gh-release@v1 - # with: - # files: rubyfmt-*.tar.gz - # fail_on_unmatched_files: true - # generate_release_notes: true - # prerelease: true - # tag_name: ${{ steps.get-latest-tag.outputs.tag }} + - name: Upload Release + uses: softprops/action-gh-release@v1 + with: + files: rubyfmt-*.tar.gz + fail_on_unmatched_files: true + generate_release_notes: true + prerelease: true + tag_name: ${{ steps.get-latest-tag.outputs.tag }} From 6876b3e5c6e09fe51d155fef7eeb1a90ce981b5a Mon Sep 17 00:00:00 2001 From: Reese Williams Date: Wed, 20 Dec 2023 05:24:25 +0000 Subject: [PATCH 4/6] yolo --- .github/workflows/preview-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview-release.yaml b/.github/workflows/preview-release.yaml index e0a74698..b0185358 100644 --- a/.github/workflows/preview-release.yaml +++ b/.github/workflows/preview-release.yaml @@ -6,7 +6,7 @@ on: - completed push: # Run only on trunk pushes that aren't a new tag release - branches: [trunk] + branches: "*" tags-ignore: "*" env: From cd9cc379ee7e8c7d676e499cd8598b4e1fc5c4e7 Mon Sep 17 00:00:00 2001 From: Reese Williams Date: Wed, 20 Dec 2023 05:44:08 +0000 Subject: [PATCH 5/6] Fix arm build location --- .github/workflows/preview-release.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/preview-release.yaml b/.github/workflows/preview-release.yaml index b0185358..0405f631 100644 --- a/.github/workflows/preview-release.yaml +++ b/.github/workflows/preview-release.yaml @@ -100,20 +100,24 @@ jobs: - source-release steps: - uses: actions/checkout@v2 + - uses: actions-ecosystem/action-get-latest-tag@v1 + id: get-latest-tag - uses: actions/download-artifact@v3 with: name: rubyfmt-source-release - uses: actions/download-artifact@v3 with: - name: rubyfmt-release-artifact-ubuntu-20.04-native + name: rubyfmt-release-artifact-ubuntu-20.04-aarch64-unknown-linux-gnu + - run: | + # The arch part of this path is set with uname, but we cross-compile the arm build on + # an x86 machine, so we want to make sure the name is correct for the release + mv rubyfmt-${{ steps.get-latest-tag.outputs.tag }}-Linux-x86_64.tar.gz rubyfmt-${{ steps.get-latest-tag.outputs.tag }}-Linux-aarch64.tar.gz - uses: actions/download-artifact@v3 with: - name: rubyfmt-release-artifact-ubuntu-20.04-aarch64-unknown-linux-gnu + name: rubyfmt-release-artifact-ubuntu-20.04-native - uses: actions/download-artifact@v3 with: name: rubyfmt-release-artifact-macos-latest-native - - uses: actions-ecosystem/action-get-latest-tag@v1 - id: get-latest-tag - name: Upload Release uses: softprops/action-gh-release@v1 with: From c81b86e13e66704ba31aed75ac980f118599dca5 Mon Sep 17 00:00:00 2001 From: Reese Williams Date: Wed, 20 Dec 2023 06:19:45 +0000 Subject: [PATCH 6/6] trunk only --- .github/workflows/preview-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview-release.yaml b/.github/workflows/preview-release.yaml index 0405f631..0764837f 100644 --- a/.github/workflows/preview-release.yaml +++ b/.github/workflows/preview-release.yaml @@ -6,7 +6,7 @@ on: - completed push: # Run only on trunk pushes that aren't a new tag release - branches: "*" + branches: [trunk] tags-ignore: "*" env: